Prechádzať zdrojové kódy

Fix test_query_counts: patch _is_parallel_test_run to avoid RuntimeError in CI

The _recorded_key helper drives assert_expected_query_count in UPDATE mode,
which raises RuntimeError when --parallel is detected in sys.argv. CI runs
the full suite with --parallel, so all three tests were failing. Patch
_is_parallel_test_run alongside _record_update so the helper works in any
execution environment.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Brian Tiemann 1 deň pred
rodič
commit
5873cccddf

+ 3 - 0
netbox/utilities/tests/test_query_counts.py

@@ -43,7 +43,9 @@ class AssertExpectedQueryCountLabelTestCase(TestCase):
         def fake_record(app_label, key, count):
             captured['key'] = key
 
+        original_parallel = qc_mod._is_parallel_test_run
         qc_mod._record_update = fake_record
+        qc_mod._is_parallel_test_run = lambda: False
         try:
             import os
             old_env = os.environ.get(qc_mod.UPDATE_ENV_VAR)
@@ -58,6 +60,7 @@ class AssertExpectedQueryCountLabelTestCase(TestCase):
                     os.environ[qc_mod.UPDATE_ENV_VAR] = old_env
         finally:
             qc_mod._record_update = original
+            qc_mod._is_parallel_test_run = original_parallel
 
         return captured['key']