A setup/teardown context manager decorator for unit tests
Project description
Setup Teardown Content Decorator
This is a simple package that aims to make adding setup and teardown to pytest flavored tests quick and painless.
Usage
class PgSetupTeardown(ContextDecorator):
def __init__(self, table, **kwargs):
self.table = table
self.__dict__.update(kwargs)
def __enter__(self):
self.session = db.session.new_session()
self.session.query(self.table).delete()
self.session.commit()
return self
def __exit__(self, typ, val, traceback):
self.session = db.session.new_session()
self.session.query(self.table).delete()
self.session.commit()
class TestHandlerDatabaseRequired:
@SetupTeardown(table="table_name")
def test_handler_success(self, mock_datetime):
"""
Example of using the SetupTeardown ContextDecorator with arbitrary setup and teardown
"""
# execute the test
pass
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
setup-teardown-0.0.1.tar.gz
(1.9 kB
view hashes)
Built Distribution
Close
Hashes for setup_teardown-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1b06fb1ff5fdd0626243a8125364b46403976cbfca7fcbb32fb86dd411b6a10 |
|
MD5 | 2bd8221022425bd10ea388cdc6b6a308 |
|
BLAKE2b-256 | c749e9d6b95b6852db20dc4d36a5bb6a5da5c55b33bef8b3b379ff517f1abb3d |