Hacks to assist with testing.
Project description
Hacks to assist with testing.
Latest release 20251020:
- Add a default base SetupTeardownMixin.setupTeardown() context manager; this should now play nicely with test cases unaware of SetupTeardownMixin.
- Remove the dependency on cs.debug.
Short summary:
assertSingleThread: Test that there is only oneThreadstill running.product_test: Decorator for test methods which should run subTests against the Cartesian products fromparams.SetupTeardownMixin: A mixin to support a singlesetupTeardown()context manager method.
Module contents:
-
assertSingleThread(include_daemon=False, exclude=None): Test that there is only oneThreadstill running.Parameters:
include_daemon: also count daemonThreads, normally skippedexclude: optionalCallable[Thread]to test for otherThreads to exclude
-
product_test(*da, **dkw): Decorator for test methods which should run subTests against the Cartesian products fromparams.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
setUpandtearDownmethods and instead is expected to provide:product_setup(self,**params): a setup method taking keyword arguments for each productproduct_teardown(self): the corresponding testdown method There are called around eachsubTest.
-
class SetupTeardownMixin: A mixin to support a singlesetupTeardown()context manager method.
SetupTeardownMixin.setUp(self):
Run super().setUp() then the set up step of self.setupTeardown().
SetupTeardownMixin.setupTeardown(self):
Base class setupTeardown context manager which does nothing.
SetupTeardownMixin.tearDown(self):
Run the tear down step of self.setupTeardown(),
then super().tearDown().
Release Log
Release 20251020:
- Add a default base SetupTeardownMixin.setupTeardown() context manager; this should now play nicely with test cases unaware of SetupTeardownMixin.
- Remove the dependency on cs.debug.
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cs_testutils-20251020.tar.gz.
File metadata
- Download URL: cs_testutils-20251020.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1773ef81455e0c568cac98de28626c2118a55e6355a49071848646ec2dc10361
|
|
| MD5 |
2b1d38456297a0ca24f0610c8d1368d3
|
|
| BLAKE2b-256 |
5bae9ad6d5f3371ca61afa669bc369ff9f200f89610cbdb6f3d3ea69669de522
|
File details
Details for the file cs_testutils-20251020-py2.py3-none-any.whl.
File metadata
- Download URL: cs_testutils-20251020-py2.py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
752733ab343b20b68d3aab4bbfc1c2b10d6368f58320dd7452a56ab1d202457e
|
|
| MD5 |
8604f1f36f915bd0b049280899330d65
|
|
| BLAKE2b-256 |
037f573b2ea35c455f8e97f2c1f42ead28c3bf7bdb510ce6bee4edd67fce9744
|