Skip to main content

Hacks to assist with testing.

Latest release 20230109:

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

Function 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.

Release Log

Release 20230109:

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

Release files for cs-testutils 20230109

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 20230109
File Size Uploaded
cs.testutils-20230109.tar.gz 3.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cs-testutils 20230109
File Interpreter ABI Platform
cs.testutils-20230109-py3-none-any.whl Python 3 none any Details

Total release size: 6.7 kB

Release files / cs.testutils-20230109.tar.gz

Download URL cs.testutils-20230109.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2ba7674970241c290fb477e1bbb37b09f84bd1ef09bc572079a5a15b739c38ab
BLAKE2b-256 checksum
How to use checksums
984fe522e5114ac88cf34519b7ad9d5c5932896139765b93d5ee3e2e3403a134
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / cs.testutils-20230109-py3-none-any.whl

Download URL cs.testutils-20230109-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6c940b99c728e4b284cf1be64521c1b6827c5a0993e5e53d2926e84a8245aa3e
BLAKE2b-256 checksum
How to use checksums
2f9c83b1b1d8e2490a07ff1d8100470e0f76797984b8a274d0c96525de7987dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release history Release notifications | RSS feed

This release

20230109 This release

2 release files

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