cs-testutils


Namecs-testutils JSON
Version 20251020 PyPI version JSON
download
home_pageNone
SummaryHacks to assist with testing.
upload_time2025-10-20 06:13:28
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseNone
keywords python3
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            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 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:
- <a name="assertSingleThread"></a>`assertSingleThread(include_daemon=False, exclude=None)`: Test that there is only one `Thread` still running.

  Parameters:
  * `include_daemon`: also count daemon `Thread`s, normally skipped
  * `exclude`: optional `Callable[Thread]` to test for other `Thread`s to exclude
- <a name="product_test"></a>`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`.
- <a name="SetupTeardownMixin"></a>`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.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.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "cs-testutils",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "python3",
    "author": null,
    "author_email": "Cameron Simpson <cs@cskk.id.au>",
    "download_url": "https://files.pythonhosted.org/packages/5b/ae/9ad6d5f3371ca61afa669bc369ff9f200f89610cbdb6f3d3ea69669de522/cs_testutils-20251020.tar.gz",
    "platform": null,
    "description": "Hacks to assist with testing.\n\n*Latest release 20251020*:\n* Add a default base SetupTeardownMixin.setupTeardown() context manager; this should now play nicely with test cases unaware of SetupTeardownMixin.\n* Remove the dependency on cs.debug.\n\nShort summary:\n* `assertSingleThread`: Test that there is only one `Thread` still running.\n* `product_test`: Decorator for test methods which should run subTests against the Cartesian products from `params`.\n* `SetupTeardownMixin`: A mixin to support a single `setupTeardown()` context manager method.\n\nModule contents:\n- <a name=\"assertSingleThread\"></a>`assertSingleThread(include_daemon=False, exclude=None)`: Test that there is only one `Thread` still running.\n\n  Parameters:\n  * `include_daemon`: also count daemon `Thread`s, normally skipped\n  * `exclude`: optional `Callable[Thread]` to test for other `Thread`s to exclude\n- <a name=\"product_test\"></a>`product_test(*da, **dkw)`: Decorator for test methods which should run subTests\n  against the Cartesian products from `params`.\n\n  A specific TestCase would define its own decorator\n  and apply it throughout the suite.\n  Here is an example from cs.vt.datadir_tests:\n\n    def multitest(test_method):\n      return product_test(\n          test_method,\n          datadirclass=[DataDir, RawDataDir],\n          indexclass=[\n              indexclass_by_name(indexname)\n              for indexname in sorted(indexclass_names())\n          ],\n          hashclass=[\n              HASHCLASS_BY_NAME[hashname]\n              for hashname in sorted(HASHCLASS_BY_NAME.keys())\n          ],\n      )\n\n  whose test suite then just decorates each method with `@multitest`:\n\n      @multitest\n      def test000IndexEntry(self):\n          ....\n\n  Note that because there must be setup and teardown for each product,\n  the TestCase class may well have empty `setUp` and `tearDown` methods\n  and instead is expected to provide:\n  * `product_setup(self,**params)`:\n    a setup method taking keyword arguments for each product\n  * `product_teardown(self)`:\n    the corresponding testdown method\n  There are called around each `subTest`.\n- <a name=\"SetupTeardownMixin\"></a>`class SetupTeardownMixin`: A mixin to support a single `setupTeardown()` context manager method.\n\n*`SetupTeardownMixin.setUp(self)`*:\nRun `super().setUp()` then the set up step of `self.setupTeardown()`.\n\n*`SetupTeardownMixin.setupTeardown(self)`*:\nBase class `setupTeardown` context manager which does nothing.\n\n*`SetupTeardownMixin.tearDown(self)`*:\nRun the tear down step of `self.setupTeardown()`,\nthen `super().tearDown()`.\n\n# Release Log\n\n\n\n*Release 20251020*:\n* Add a default base SetupTeardownMixin.setupTeardown() context manager; this should now play nicely with test cases unaware of SetupTeardownMixin.\n* Remove the dependency on cs.debug.\n\n*Release 20250426*:\nUpdate DISTINFO.\n\n*Release 20241122*:\nassertSingleThread: new optional exclude parameter which is a callable to test where a Thread should be ignored.\n\n*Release 20240623*:\nNew assertSingleThread() function to check that there are no left over Threads.\n\n*Release 20230109*:\n* @product_test decorator for running test matrices.\n* SetupTeardownMixin providing unittest setUp/tearDown from setupTeardown context manager method.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Hacks to assist with testing.",
    "version": "20251020",
    "project_urls": {
        "MonoRepo Commits": "https://bitbucket.org/cameron_simpson/css/commits/branch/main",
        "Monorepo Git Mirror": "https://github.com/cameron-simpson/css",
        "Monorepo Hg/Mercurial Mirror": "https://hg.sr.ht/~cameron-simpson/css",
        "Source": "https://github.com/cameron-simpson/css/blob/main/lib/python/cs/testutils.py"
    },
    "split_keywords": [
        "python3"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "037f573b2ea35c455f8e97f2c1f42ead28c3bf7bdb510ce6bee4edd67fce9744",
                "md5": "8604f1f36f915bd0b049280899330d65",
                "sha256": "752733ab343b20b68d3aab4bbfc1c2b10d6368f58320dd7452a56ab1d202457e"
            },
            "downloads": -1,
            "filename": "cs_testutils-20251020-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8604f1f36f915bd0b049280899330d65",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 4445,
            "upload_time": "2025-10-20T06:13:27",
            "upload_time_iso_8601": "2025-10-20T06:13:27.224023Z",
            "url": "https://files.pythonhosted.org/packages/03/7f/573b2ea35c455f8e97f2c1f42ead28c3bf7bdb510ce6bee4edd67fce9744/cs_testutils-20251020-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "5bae9ad6d5f3371ca61afa669bc369ff9f200f89610cbdb6f3d3ea69669de522",
                "md5": "2b1d38456297a0ca24f0610c8d1368d3",
                "sha256": "1773ef81455e0c568cac98de28626c2118a55e6355a49071848646ec2dc10361"
            },
            "downloads": -1,
            "filename": "cs_testutils-20251020.tar.gz",
            "has_sig": false,
            "md5_digest": "2b1d38456297a0ca24f0610c8d1368d3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3444,
            "upload_time": "2025-10-20T06:13:28",
            "upload_time_iso_8601": "2025-10-20T06:13:28.514175Z",
            "url": "https://files.pythonhosted.org/packages/5b/ae/9ad6d5f3371ca61afa669bc369ff9f200f89610cbdb6f3d3ea69669de522/cs_testutils-20251020.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-20 06:13:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cameron-simpson",
    "github_project": "css",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "cs-testutils"
}
        
Elapsed time: 2.14862s