Skip to main content

Setup Teardown Content Decorator

This is a simple package that aims to make adding setup and teardown to pytest flavored tests quick and painless.

Installation

python3 -m pip install setup-teardown

Provided Postgres Database Class Decorator Usage

Extend and implement the session.

class TableScrub(PostgresScrub):
    """Extend to add session."""

    @cached_property
    def session(self):
        """Only fetch the session one time."""
        return new_session()

Example class with decorator usage

class TestHandlerDatabaseRequired:
    @TableScrub(table="table_name")
    def test_handler_success(self, mock_datetime):
        """
        Example of using the SetupTeardown ContextDecorator
        with arbitrary setup and teardown.
        """
        assert 1 == 1
        # Effect the database test that may leave db in dirty state

Example function with decorator usage

    @TableScrub(table="table_name")
    def test_insert():
        with TableScrub(setup=setup, teardown=teardown):
            assert 1 == 1
            # Effect the database test that may leave db in dirty state

Example function with context manager usage

    def setup(self):
        db.session.new_session().query(self.table).delete()

    def teardown(self):
        db.session.new_session().query(self.table).delete()


    def test_insert():
        with SetupTeardown(setup=setup, teardown=teardown):
            assert 1 == 1
            # Effect the database test that may leave db in dirty state

Metadata

Release files for setup-teardown 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for setup-teardown 0.0.5
File Size Uploaded Provenance
setup-teardown-0.0.5.tar.gz 3.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for setup-teardown 0.0.5
File Interpreter ABI Platform
setup_teardown-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 6.6 kB

Release files / setup-teardown-0.0.5.tar.gz

Download URL setup-teardown-0.0.5.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a32cd001a7340cd6a03c3eb4cf311479f24aa5f6516218079fbcf421710348d8
BLAKE2b-256 checksum
How to use checksums
68849d2f305a9a3d5ea50f06834cc1f8f949e40072e43ccb43f5c6faebe5863a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.0.1 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / setup_teardown-0.0.5-py3-none-any.whl

Download URL setup_teardown-0.0.5-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c3f9f0a4b60bbf29741c31917abcc9ec7de8ecc2945f27e5b85dc88ee9cc172
BLAKE2b-256 checksum
How to use checksums
074df5d2ebf03483b60ac3c34af47f5477f1a9597f20544aafbe583e19c0f565
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.0.1 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Security for setup-teardown 0.0.5

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.

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