diff options
author | Frederick Muriuki Muriithi | 2022-11-14 18:02:55 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-11-14 18:02:55 +0300 |
commit | baf7980cd6080c8cb4e6c6b585948144273600aa (patch) | |
tree | 25e1693fe3953c5f8ef2acb8710c458314b46162 /tests/unit/conftest.py | |
parent | 7ef618e88c4a6b04ca477213858810fc95685f4e (diff) | |
download | genenetwork3-baf7980cd6080c8cb4e6c6b585948144273600aa.tar.gz |
tests: split test app and test client
* The test app and the test client are both needed as fixtures in different
places
Diffstat (limited to 'tests/unit/conftest.py')
-rw-r--r-- | tests/unit/conftest.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index a2b562e..9660c32 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -8,20 +8,25 @@ import pytest from gn3.app import create_app @pytest.fixture(scope="session") -def client(): - """Create a test client fixture for tests""" +def test_app(): # Do some setup with TemporaryDirectory() as testdir: testdb = Path(testdir).joinpath( f'testdb_{datetime.now().strftime("%Y%m%dT%H%M%S")}') - app = create_app({"AUTH_DB": testdb}) - app.config.update({"TESTING": True}) + app = create_app() + app.config.update({"TESTING": True, "AUTH_DB": testdb}) app.testing = True - yield app.test_client() + yield app # Clean up after ourselves testdb.unlink(missing_ok=True) @pytest.fixture(scope="session") +def client(test_app): + """Create a test client fixture for tests""" + with test_app.app_context(): + yield test_app.test_client() + +@pytest.fixture(scope="session") def test_app_config(client): # pylint: disable=redefined-outer-name """Return the test application's configuration object""" return client.application.config |