From d978bd4eefd4b38cda1840a5836771db2173c8aa Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Tue, 11 Dec 2018 14:09:09 +0100 Subject: [PATCH] tests: skip test_database without DATABASE_URL (#263) * tests: skip test_database without DATABASE_URL (instead of causing a collection error) * fixup! tests: skip test_database without DATABASE_URL --- tests/test_database.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_database.py b/tests/test_database.py index 803772a0..c287c8ab 100644 --- a/tests/test_database.py +++ b/tests/test_database.py @@ -9,7 +9,10 @@ from starlette.middleware.database import DatabaseMiddleware from starlette.responses import JSONResponse from starlette.testclient import TestClient -DATABASE_URL = os.environ["STARLETTE_TEST_DATABASE"] +try: + DATABASE_URL = os.environ["STARLETTE_TEST_DATABASE"] +except KeyError: # pragma: no cover + pytest.skip("DATABASE_URL is not set", allow_module_level=True) metadata = sqlalchemy.MetaData()