Improved TestCase Class
dectest.TestCase is a drop-in replacement for unittest.TestCase with
a few added features.
Tests, Setup, and Teardown with Decorators
Tests can optionally be marked using the @test decorator, instead of
prefixing the method name with test. The following test case class
contains two tests:
from dectest import TestCase, test
class MyTest(TestCase):
def test_foo(self):
pass
@test
def bar(self):
pass
Setup and teardown methods can be marked using the @before and @after
decorators, respectively. A class can have multiple setup and teardown
methods:
from dectest import TestCase, before, after
class MyTest(TestCase):
@before
def setup_stuff(self):
pass
@before
def setup_more_stuff(self):
pass
@after
def teardown_all_stuff(self):
pass
While the order of execution inside a class is undefined and should not be relied upon, it is guaranteed that setup methods in super-classes are executed before methods in sub-classes, and teardown methods in sub-classes are executed before teardown method in super-classes:
from dectest import TestCase, before, after
class MySuperTest(TestCase):
@before
def super_setup(self):
print("setup first")
@after
def super_teardown(self):
print("teardown second")
class MySubTest(MySuperTest):
@before
def sub_setup(self):
print("setup second")
@after
def sub_teardown(self):
print("teardown first")
Patch Support
dectest.TestCase has a patch() method to install a mock using
unittest.mock.patch(). This patch is removed during test
teardown:
from dectest import TestCase, test
class MyPatchTest(TestCase):
@test
def foo(self):
exit = self.patch("sys.exit") # will be stopped during teardown
# call implementation
exit.assert_called_with(1)
Metadata
Release files for dectest 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dectest-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for dectest-1.1.1-py3-none-any.whl |
Release files / dectest-1.1.1-py3-none-any.whl
| Download URL | dectest-1.1.1-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
699e3ade7853448306e1471ed2e4b9e2c229e381a17c05fb3c8f2363ec8f71d5
|
|
BLAKE2b-256 checksum How to use checksums |
ff999605a8b6db98c44f338c7b4429cb87c8826d47c85ee2b42e96793fd224ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.3
|
Security for dectest 1.1.1
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.