Skip to main content

Hacks to assist with testing.

Latest release 20250426: Update DISTINFO.

Short summary:

  • assertSingleThread: Test that there is only one Thread still running.
  • product_test: Decorator for test methods which should run subTests against the Cartesian products from params.
  • SetupTeardownMixin: A mixin to support a single setupTeardown() context manager method.

Module contents:

  • assertSingleThread(include_daemon=False, exclude=None): Test that there is only one Thread still running.

    Parameters:

    • include_daemon: also count daemon Threads, normally skipped
    • exclude: optional Callable[Thread] to test for other Threads to exclude
  • product_test(*da, **dkw): Decorator for test methods which should run subTests against the Cartesian products from params.

    A specific TestCase would define its own decorator and apply it throughout the suite. Here is an example from cs.vt.datadir_tests:

    def multitest(test_method): return product_test( test_method, datadirclass=[DataDir, RawDataDir], indexclass=[ indexclass_by_name(indexname) for indexname in sorted(indexclass_names()) ], hashclass=[ HASHCLASS_BY_NAME[hashname] for hashname in sorted(HASHCLASS_BY_NAME.keys()) ], )

    whose test suite then just decorates each method with @multitest:

    @multitest
    def test000IndexEntry(self):
        ....
    

    Note that because there must be setup and teardown for each product, the TestCase class may well have empty setUp and tearDown methods and instead is expected to provide:

    • product_setup(self,**params): a setup method taking keyword arguments for each product
    • product_teardown(self): the corresponding testdown method There are called around each subTest.
  • Class SetupTeardownMixin: A mixin to support a single setupTeardown()` context manager method.

SetupTeardownMixin.setUp(self): Run super().setUp() then the set up step of self.setupTeardown().

SetupTeardownMixin.tearDown(self): Run the tear down step of self.setupTeardown(), then super().tearDown().

Release Log

Release 20250426: Update DISTINFO.

Release 20241122: assertSingleThread: new optional exclude parameter which is a callable to test where a Thread should be ignored.

Release 20240623: New assertSingleThread() function to check that there are no left over Threads.

Release 20230109:

  • @product_test decorator for running test matrices.
  • SetupTeardownMixin providing unittest setUp/tearDown from setupTeardown context manager method.

Metadata

Release files for cs-testutils 20250426

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

Source distribution (sdist)

Source distribution for cs-testutils 20250426
File Size Uploaded Provenance Actions
cs_testutils-20250426.tar.gz 3.3 kB Without provenance Details for cs_testutils-20250426.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cs-testutils 20250426
File Interpreter ABI Platform Actions
cs_testutils-20250426-py2.py3-none-any.whl Python 2, Python 3 none any Details for cs_testutils-20250426-py2.py3-none-any.whl

Total release size: 7.6 kB

Release files / cs_testutils-20250426.tar.gz

Download URL cs_testutils-20250426.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b36b3465bac1f0b38121a36521d2fc554eb9d30ea1364085837f56d2922c73cf
BLAKE2b-256 checksum
How to use checksums
7029c5d0e19ad1f226d80823974ed4c20b64239c66f715f5199af241b4cd5d95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / cs_testutils-20250426-py2.py3-none-any.whl

Download URL cs_testutils-20250426-py2.py3-none-any.whl
Size 4.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
0910e6fefae29746f3d0c6dabc6c2479c6c1330e6d0629ff922a08670367e6e7
BLAKE2b-256 checksum
How to use checksums
170aa90ae0f1d04c4d689d7fa6502262099d5bd523dc5ec0f2e1b67bbefd93f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Security for cs-testutils 20250426

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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