We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cb8d108 commit 9f6f211Copy full SHA for 9f6f211
python-stdlib/unittest/unittest.py
@@ -10,6 +10,13 @@
10
traceback = None
11
12
13
+def _snapshot_modules():
14
+ return {k: v for k, v in sys.modules.items()}
15
+
16
17
+__modules__ = _snapshot_modules()
18
19
20
class SkipTest(Exception):
21
pass
22
@@ -375,6 +382,13 @@ def _test_cases(mod):
375
382
376
383
377
384
def run_module(runner, module, path, top):
385
+ if not module:
386
+ raise ValueError("Empty module name")
387
388
+ # Reset the python environment before running test
389
+ sys.modules.clear()
390
+ sys.modules.update(__modules__)
391
378
392
sys_path_initial = sys.path[:]
379
393
# Add script dir and top dir to import path
380
394
sys.path.insert(0, str(path))
@@ -395,6 +409,8 @@ def run_module(runner, module, path, top):
395
409
def discover(runner: TestRunner):
396
410
from unittest_discover import discover
397
411
412
+ global __modules__
413
+ __modules__ = _snapshot_modules()
398
414
return discover(runner=runner)
399
415
400
416
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments