Browse Source

fix(COGS) Fix accountant test not to rely on atexit (#61235)

Using `atexit` in the test is making other tests fail. 
This should fix it.
Filippo Pacifici 1 year ago
parent
commit
399d66ed9f
1 changed files with 1 additions and 4 deletions
  1. 1 4
      tests/sentry/usage_accountant/test_accountant.py

+ 1 - 4
tests/sentry/usage_accountant/test_accountant.py

@@ -1,8 +1,6 @@
-import atexit
 from typing import Optional
 from unittest import mock
 
-import pytest
 from arroyo.backends.kafka.consumer import KafkaPayload
 from arroyo.backends.local.backend import LocalBroker
 from arroyo.backends.local.storages.memory import MemoryMessageStorage
@@ -36,7 +34,6 @@ def assert_msg(
     }
 
 
-@pytest.mark.skip(reason="usage of atexit breaks interpreter")
 @django_db_all
 @mock.patch("time.time")
 def test_accountant(mock_time: mock.Mock) -> None:
@@ -54,7 +51,7 @@ def test_accountant(mock_time: mock.Mock) -> None:
     record("resource_1", "feature_1", 100, UsageUnit.BYTES)
     record("resource_1", "feature_2", 100, UsageUnit.BYTES)
 
-    atexit._run_exitfuncs()
+    accountant._shutdown()
 
     msg1 = broker.consume(Partition(topic, 0), 0)
     assert_msg(