Skip to content

Commit

Permalink
drop unnecessary asyncio test markers
Browse files Browse the repository at this point in the history
  • Loading branch information
albertodonato committed Oct 29, 2024
1 parent 5c21517 commit 9b296f8
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 22 deletions.
21 changes: 0 additions & 21 deletions tests/db_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ def test_results_wrong_names_with_labels(self):


class TestQueryResults:
@pytest.mark.asyncio
async def test_from_results(self):
"""The from_results method creates a QueryResult."""
engine = create_engine("sqlite://", strategy=ASYNCIO_STRATEGY)
Expand All @@ -314,7 +313,6 @@ async def test_from_results(self):
assert query_results.latency is None
assert query_results.timestamp < time.time()

@pytest.mark.asyncio
async def test_from_results_with_latency(self):
"""The from_results method creates a QueryResult."""
engine = create_engine("sqlite://", strategy=ASYNCIO_STRATEGY)
Expand Down Expand Up @@ -351,7 +349,6 @@ def test_instantiate(self, db_config):
assert db.config is db_config
assert db.logger == logging.getLogger()

@pytest.mark.asyncio
async def test_as_context_manager(self, db):
"""The database can be used as an async context manager."""
async with db:
Expand All @@ -360,22 +357,19 @@ async def test_as_context_manager(self, db):
# the db is closed at context exit
assert not db.connected

@pytest.mark.asyncio
async def test_connect(self, caplog, db):
"""The connect connects to the database."""
with caplog.at_level(logging.DEBUG):
await db.connect()
assert isinstance(db._conn, AsyncConnection)
assert caplog.messages == ['connected to database "db"']

@pytest.mark.asyncio
async def test_connect_lock(self, caplog, db):
"""The connect method has a lock to prevent concurrent calls."""
with caplog.at_level(logging.DEBUG):
await asyncio.gather(db.connect(), db.connect())
assert caplog.messages == ['connected to database "db"']

@pytest.mark.asyncio
async def test_connect_error(self):
"""A DataBaseConnectError is raised if database connection fails."""
config = DataBaseConfig(name="db", dsn="sqlite:////invalid")
Expand All @@ -384,7 +378,6 @@ async def test_connect_error(self):
await db.connect()
assert "unable to open database file" in str(error.value)

@pytest.mark.asyncio
async def test_connect_sql(self):
"""If connect_sql is specified, it's run at connection."""
config = DataBaseConfig(
Expand All @@ -404,7 +397,6 @@ async def execute_sql(sql):
assert queries == ["SELECT 1", "SELECT 2"]
await db.close()

@pytest.mark.asyncio
async def test_connect_sql_fail(self, caplog):
"""If the SQL at connection fails, an error is raised."""
config = DataBaseConfig(
Expand All @@ -422,7 +414,6 @@ async def test_connect_sql_fail(self, caplog):
assert 'failed executing query "WRONG"' in str(error.value)
assert 'disconnected from database "db"' in caplog.messages

@pytest.mark.asyncio
async def test_close(self, caplog, db):
"""The close method closes database connection."""
await db.connect()
Expand All @@ -433,7 +424,6 @@ async def test_close(self, caplog, db):
assert connection.closed
assert db._conn is None

@pytest.mark.asyncio
async def test_execute_log(self, db, caplog):
"""A message is logged about the query being executed."""
query = Query(
Expand All @@ -449,7 +439,6 @@ async def test_execute_log(self, db, caplog):
await db.close()

@pytest.mark.parametrize("connected", [True, False])
@pytest.mark.asyncio
async def test_execute_keep_connected(self, mocker, connected):
"""If keep_connected is set to true, the db is not closed."""
config = DataBaseConfig(
Expand All @@ -472,7 +461,6 @@ async def test_execute_keep_connected(self, mocker, connected):
mock_conn_detach.assert_called_once()
await db.close()

@pytest.mark.asyncio
async def test_execute_no_keep_disconnect_after_pending_queries(self):
"""The db is disconnected only after pending queries are run."""
config = DataBaseConfig(
Expand All @@ -495,7 +483,6 @@ async def test_execute_no_keep_disconnect_after_pending_queries(self):
await asyncio.gather(db.execute(query1), db.execute(query2))
assert not db.connected

@pytest.mark.asyncio
async def test_execute_not_connected(self, db):
"""The execute recconnects to the database if not connected."""
query = Query(
Expand All @@ -506,7 +493,6 @@ async def test_execute_not_connected(self, db):
# the connection is kept for reuse
assert not db._conn.closed

@pytest.mark.asyncio
async def test_execute(self, db):
"""The execute method executes a query."""
sql = (
Expand All @@ -529,7 +515,6 @@ async def test_execute(self, db):
]
assert isinstance(metric_results.latency, float)

@pytest.mark.asyncio
async def test_execute_with_labels(self, db):
"""The execute method executes a query with labels."""
sql = """
Expand Down Expand Up @@ -559,7 +544,6 @@ async def test_execute_with_labels(self, db):
MetricResult("metric2", 33, {"label2": "baz"}),
]

@pytest.mark.asyncio
async def test_execute_query_invalid_count(self, caplog, db):
"""If the number of fields don't match, an error is raised."""
query = Query(
Expand All @@ -584,7 +568,6 @@ async def test_execute_query_invalid_count(self, caplog, db):
"Wrong result count from query: expected 1, got 2"
]

@pytest.mark.asyncio
async def test_execute_query_invalid_count_with_labels(self, db):
"""If the number of fields don't match, an error is raised."""
query = Query(
Expand All @@ -602,7 +585,6 @@ async def test_execute_query_invalid_count_with_labels(self, db):
)
assert error.value.fatal

@pytest.mark.asyncio
async def test_execute_query_invalid_names_with_labels(self, db):
"""If the names of fields don't match, an error is raised."""
query = Query(
Expand All @@ -620,7 +602,6 @@ async def test_execute_query_invalid_names_with_labels(self, db):
)
assert error.value.fatal

@pytest.mark.asyncio
async def test_execute_query_traceback_debug(self, caplog, mocker, db):
"""Traceback are logged as debug messages."""
query = Query(
Expand All @@ -646,7 +627,6 @@ async def test_execute_query_traceback_debug(self, caplog, mocker, db):
# traceback is included in messages
assert "await self._execute_query(query)" in caplog.messages[-1]

@pytest.mark.asyncio
async def test_execute_timeout(self, caplog, db):
"""If the query times out, an error is raised and logged."""
query = Query(
Expand Down Expand Up @@ -676,7 +656,6 @@ async def execute(sql, parameters):
'Execution for query "query" expired after 0.1 seconds'
]

@pytest.mark.asyncio
async def test_execute_sql(self, db):
"""It's possible to execute raw SQL."""
await db.connect()
Expand Down
1 change: 0 additions & 1 deletion tests/loop_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ def test_expire_series(self, metrics_expiration):
}


@pytest.mark.asyncio
class TestQueryLoop:
async def test_start(self, query_loop):
"""The start method starts timed calls for queries."""
Expand Down

0 comments on commit 9b296f8

Please sign in to comment.