Skip to content

Commit 8acdf05

Browse files
author
Nils Bars
committed
Suppress run_tests() during submission_tests module loading
Prevents double test execution when submission_tests scripts call rf.run_tests() at module level. The suppression is active only during import; task.py then calls run_tests() itself afterward.
1 parent b44e212 commit 8acdf05

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

ref-docker-base/task.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from itsdangerous import TimedSerializer
1515

1616
from ref_utils import TaskTestResult, print_err, print_ok, print_warn
17-
from ref_utils.decorator import run_tests
17+
from ref_utils.decorator import run_tests, suppress_run_tests
1818

1919
with open("/etc/key", "rb") as f:
2020
KEY = f.read()
@@ -127,8 +127,12 @@ def _run_tests(
127127
print_warn("[+] No testsuite found! Skipping tests..")
128128
return "No testsuite found! Skipping tests..", []
129129

130-
# Load submission_tests as a module (this registers tests via decorators)
130+
# Load submission_tests as a module (this registers tests via decorators).
131+
# Suppress run_tests() during import to prevent double execution, since
132+
# some scripts call rf.run_tests() at module level.
133+
suppress_run_tests(True)
131134
_load_submission_tests_module()
135+
suppress_run_tests(False)
132136

133137
# Capture stdout/stderr during test execution
134138
from io import StringIO

0 commit comments

Comments
 (0)