diff options
author | boris <boris@verhovs.ky> | 2019-08-06 13:34:58 -0700 |
---|---|---|
committer | boris <boris@verhovs.ky> | 2019-08-06 13:34:58 -0700 |
commit | 5f95dce95602921a70bfbc7d8de2f7712c5e4505 (patch) | |
tree | 681fb33747fc5a3be3ff747ccc9978207df69cb7 /doc/en/funcarg_compare.rst | |
parent | 75d0b899bbb56d6849e9d69d83a9426ed3f43f8b (diff) | |
download | pytest-5f95dce95602921a70bfbc7d8de2f7712c5e4505.tar.gz |
ran blacken-docs
Diffstat (limited to 'doc/en/funcarg_compare.rst')
-rw-r--r-- | doc/en/funcarg_compare.rst | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/doc/en/funcarg_compare.rst b/doc/en/funcarg_compare.rst index 131ceb1ae..2f6e7a1ec 100644 --- a/doc/en/funcarg_compare.rst +++ b/doc/en/funcarg_compare.rst @@ -29,13 +29,15 @@ a per-session Database object:: class Database: def __init__(self): print("database instance created") + def destroy(self): print("database instance destroyed") + def pytest_funcarg__db(request): - return request.cached_setup(setup=DataBase, - teardown=lambda db: db.destroy, - scope="session") + return request.cached_setup( + setup=DataBase, teardown=lambda db: db.destroy, scope="session" + ) There are several limitations and difficulties with this approach: @@ -100,7 +102,7 @@ sets. pytest-2.3 introduces a decorator for use on the factory itself:: @pytest.fixture(params=["mysql", "pg"]) def db(request): - ... # use request.param + ... # use request.param Here the factory will be invoked twice (with the respective "mysql" and "pg" values set as ``request.param`` attributes) and all of |