Hacks to assist with testing.
Latest release 20241122: assertSingleThread: new optional exclude parameter which is a callable to test where a Thread should be ignored.
assertSingleThread(include_daemon=False, exclude=None)
Test that there is only one Thread still 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 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 productproduct_teardown(self): the corresponding testdown method There are called around eachsubTest.
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 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.
Release files for cs-testutils 20241122
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cs_testutils-20241122.tar.gz | 3.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cs_testutils-20241122-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.1 kB
Release files / cs_testutils-20241122.tar.gz
| Download URL | cs_testutils-20241122.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
39704928812f3a2147f33c043e1bd37e6eca0bc174d066798ece7f18386975aa
|
|
BLAKE2b-256 checksum How to use checksums |
177ba53b272e1a0692d52a329ad2eb5841a3ccb30fd69de1ff34da914d53b8d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.6
|
Release files / cs_testutils-20241122-py3-none-any.whl
| Download URL | cs_testutils-20241122-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
98d5b98bcaa6d2ac05850427bca39bac3a803d4ad5180f9c4ec057fe5967eeb9
|
|
BLAKE2b-256 checksum How to use checksums |
11d598d045706dc6f8ef2ad1d5eac25f156d5a18b713d99b93b160780064eb78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.6
|