You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
927 B
29 lines
927 B
"""Smoke test for the migration test_db fixture.
|
|
|
|
This test imports the `test_db` fixture and asserts expected behavior in two
|
|
cases:
|
|
|
|
- If the environment variable TEST_DB_URL is not set, the fixture should yield
|
|
None.
|
|
- If TEST_DB_URL is set, the fixture should yield a connection-like object
|
|
(we check for an object with a `cursor` attribute or the sqlite3 connection
|
|
type).
|
|
"""
|
|
|
|
import os
|
|
import types
|
|
|
|
import pytest
|
|
|
|
|
|
def test_migration_fixture_smoke(test_db):
|
|
"""Smoke test ensuring the test_db fixture yields expected values."""
|
|
url = os.environ.get("TEST_DB_URL")
|
|
if not url:
|
|
assert test_db is None
|
|
else:
|
|
# For sqlite we expect a sqlite3.Connection which has a 'cursor'
|
|
# method. Be permissive and accept any object with a 'cursor'
|
|
# attribute or callable.
|
|
assert test_db is not None
|
|
assert hasattr(test_db, "cursor") or hasattr(test_db, "execute")
|
|
|