Skip to main content

kissut - Python Unittesting Utilities

Provides a simple automatic test case that sets up a new log each time tests are run. Also provides some basic methods to assist with configuration and file management when running tests

Usage

Installation:

    pip install kissut

LoggingTestCase subclasses unittest.TestCase, so when creating your tests, simply subclass LoggingTestCase instead of TestCase. LoggingTestCase sets up a unittest directory wkdir/unittest/ and saves log directories there:

from kissut import LoggingTestCase
import os

# all test classes must derive from unittest.TestCase, which LoggingTestCase does...
class TestExample(LoggingTestCase):
    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        # this loads the test configuration file
        cls.cfg = cls.getConfig()

    def test_a_isTrue(self):
        s = self.randString()
        self.logger.debug("s: {}".format(s))
        self.assertTrue(s)

    def test_b_saveWorkData(self):
        self.cfg["data"] = "testData.json"
        fqfn = self.dumpWkDirData(data={"a": "b"}, filename=self.cfg["data"])
        self.logger.debug("file name: {}".format(self.cfg["data"]))
        self.assertTrue(os.path.exists(fqfn))

    def test_c_isPresent(self):
        self.logger.debug("cfg: {}".format(self.cfg))
        d = self.loadWkDirData(self.cfg["data"])
        self.logger.debug("data: {}".format(d))
        self.assertIsNotNone(d)

This produces the following directory structure after running it twice (the first time will abort as it creates the config file):

<project folder>
└── wkdir
    └── unittest
        ├── 20260306T155251
        │   └── log.txt
        ├── 20260306T160132
        │   ├── log.txt
        │   └── testData.json
        └── testConfig.json

Obviously loading a config file in the setUpClass method is not required, it is just something I find useful, especially when a connection string or url is required for testing.

Some additional things to note, a simple random string method is included, as are dump and save methods for data to the working directory, and an initialized logger on the test case object.

If you prefer to save the logs or test config in another location, create a session-specific or user environment variable that defines path to the alternative configuration file. The contents of the alternative configuration file should be formatted like the following, obviously replacing the values as appropriate:

{
    "logCfgFile": "wkdir/alt_unittest/logConfig.json",
    "testCfgFile": "wkdir/alt_unittest/testConfig.json"
}

Cloning For Development

Set up a virtual environment. Once an environment is set up, activate it and add dependencies with the following:

    pip install -r requirements/dev.txt

The dev.txt file includes:

  • BLACK, a code formatter, see notes at the bottom of this file for details
  • build, which provides the support for the building of the package

To run tests:

    python -m unittest discover -s tests/

The run the following to confirm the alternative configuration works, ensuring the unittest configuration and log directories get saved in the wkdir/alt_unittest directory:

    source tests/runAltUnittest.sh

Does the same thing as

    export KISSUT_CFG_FILE="tests/altConfig.json"
    python -m unittest discover -s tests/

Code Formatting

Code formatting is done using BLACK. BLACK allows almost no customization to how code is formatted with the exception of line length, which has been set to 119 characters.

Use the following to bulk format files:

    black . -l 144

Creating A New Release

Please do the following when making a new release, most are documented above:

  1. Run tests
  2. Code format
  3. Be sure to update the change log and _metadata.json with version and notes
  4. git add, commit, and push changes
  5. run the following code to generate a wheel:
    python -m build

Metadata

Release files for kissut 1.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kissut 1.2.2
File Size Uploaded Provenance Actions
kissut-1.2.2.tar.gz 9.8 kB With provenance Details for kissut-1.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kissut 1.2.2
File Interpreter ABI Platform Actions
kissut-1.2.2-py3-none-any.whl Python 3 none any Details for kissut-1.2.2-py3-none-any.whl

Total release size: 19.0 kB

Release files / kissut-1.2.2.tar.gz

Download URL kissut-1.2.2.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
63ef37538f693bd0f7b00e1334fd5e03fe72cfc69802ed103cf0a0518696f9a1
BLAKE2b-256 checksum
How to use checksums
49368d40de5fc42aa6e9f7ca7f0214871f63b862d51ebf99acd478c52fd7641b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 1, 2026.

Transparency log

Release files / kissut-1.2.2-py3-none-any.whl

Download URL kissut-1.2.2-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c7c75507c0ed561a9dba1c6f70d7f6c83792e2aa0eb420dc9c3ad01d0d4930c1
BLAKE2b-256 checksum
How to use checksums
42a45cb133d4adbaf8160d5e1e7535199eb75f309ee19848db0f9c0fd4a79600
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 1, 2026.

Transparency log

Security for kissut 1.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for kissut-1.2.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page