Karthikeyan Singaravelan <[email protected]> added the comment:
I guess this could be due to loading the module twice where the warning is not
emitted again on reimport which test__all__ seems to do so by importing
lib2to3. One obvious fix would be to pass quiet=True. Else we need to find a
way to import the module fresh like using import_fresh_module. Two possible
patches. I assumed running tests sequentially will provide support for
isolation too.
Optional argument:
- if 'quiet' is True, it does not fail if a filter catches nothing
(default True without argument,
default False if some filters are defined)
Without argument, it defaults to:
check_warnings(("", Warning), quiet=True)
# Using import fresh module
diff --git a/Lib/test/test_lib2to3.py b/Lib/test/test_lib2to3.py
index 159a8387e4..861ae5ad53 100644
--- a/Lib/test/test_lib2to3.py
+++ b/Lib/test/test_lib2to3.py
@@ -1,7 +1,9 @@
import unittest
+from test.support.import_helper import import_fresh_module
from test.support.warnings_helper import check_warnings
with check_warnings(("", PendingDeprecationWarning)):
+ lib2to3 = import_fresh_module("lib2to3")
from lib2to3.tests import load_tests
if __name__ == '__main__':
# Passing quiet=True
diff --git a/Lib/test/test_lib2to3.py b/Lib/test/test_lib2to3.py
index 159a8387e4..e4c5cade8b 100644
--- a/Lib/test/test_lib2to3.py
+++ b/Lib/test/test_lib2to3.py
@@ -1,7 +1,7 @@
import unittest
from test.support.warnings_helper import check_warnings
-with check_warnings(("", PendingDeprecationWarning)):
+with check_warnings(("", PendingDeprecationWarning), quiet=True):
from lib2to3.tests import load_tests
if __name__ == '__main__':
➜ cpython git:(master) ✗ ./python -m test test_lib2to3 test_lib2to3
0:00:00 load avg: 0.01 Run tests sequentially
0:00:00 load avg: 0.01 [1/2] test_lib2to3
0:00:13 load avg: 0.23 [2/2] test_lib2to3
== Tests result: SUCCESS ==
All 2 tests OK.
Total duration: 27.3 sec
Tests result: SUCCESS
----------
versions: +Python 3.10
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue41970>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com