From d430201e60a2d911f58bb979b1eca6299bbc96c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Tue, 25 Jun 2024 12:34:11 +0200 Subject: [PATCH] CI tests fix for Python 3.13 We should not unimport pathlib when we use pathlib. This was always fragile. Choose a module we don't use: The failure: ______________________ test_modules_from_files_are_found _______________________ tmp_path = PosixPath('/tmp/pytest-of-root/pytest-0/test_modules_from_files_are_fo0') def test_modules_from_files_are_found(tmp_path): test_file_1 = tmp_path / 'this_is_a_file_in_tmp_path_1.txt' test_file_2 = tmp_path / 'this_is_a_file_in_tmp_path_2.txt' test_file_3 = tmp_path / 'this_is_a_file_in_tmp_path_3.txt' test_file_1.write_text('math\nwave\n') test_file_2.write_text('csv\npathlib\n') test_file_3.write_text('logging\ncsv\n') # Make sure the tested modules are not already in sys.modules for m in ('math', 'wave', 'csv', 'pathlib', 'logging'): sys.modules.pop(m, None) > modules_main(['-f', str(test_file_1), '-f', str(test_file_2), '-f', str(test_file_3), ]) test_import_all_modules.py:170: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/rpm/redhat/import_all_modules.py:167: in main import_modules(modules) /usr/lib/rpm/redhat/import_all_modules.py:100: in import_modules importlib.import_module(module) /usr/lib64/python3.13/importlib/__init__.py:88: in import_module return _bootstrap._gcd_import(name[level:], package, level) :1387: in _gcd_import ??? :1360: in _find_and_load ??? :1331: in _find_and_load_unlocked ??? :935: in _load_unlocked ??? :1022: in exec_module ??? :488: in _call_with_frames_removed ??? _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ """Object-oriented filesystem paths. This module provides classes to represent abstract paths and concrete paths with operations that have semantics appropriate for different operating systems. """ from ._abc import * from ._local import * > __all__ = (_abc.__all__ + _local.__all__) E NameError: name '_abc' is not defined. Did you forget to import '_abc'? /usr/lib64/python3.13/pathlib/__init__.py:11: NameError ----------------------------- Captured stderr call ----------------------------- Check import: math Check import: wave Check import: csv Check import: pathlib --- tests/test_import_all_modules.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_import_all_modules.py b/tests/test_import_all_modules.py index 71feeff..8b89bc4 100644 --- a/tests/test_import_all_modules.py +++ b/tests/test_import_all_modules.py @@ -160,15 +160,15 @@ def test_modules_from_files_are_found(tmp_path): test_file_3 = tmp_path / 'this_is_a_file_in_tmp_path_3.txt' test_file_1.write_text('math\nwave\n') - test_file_2.write_text('csv\npathlib\n') + test_file_2.write_text('csv\nnetrc\n') test_file_3.write_text('logging\ncsv\n') # Make sure the tested modules are not already in sys.modules - for m in ('math', 'wave', 'csv', 'pathlib', 'logging'): + for m in ('math', 'wave', 'csv', 'netrc', 'logging'): sys.modules.pop(m, None) modules_main(['-f', str(test_file_1), '-f', str(test_file_2), '-f', str(test_file_3), ]) - for module in ('csv', 'math', 'wave', 'pathlib', 'logging'): + for module in ('csv', 'math', 'wave', 'netrc', 'logging'): assert module in sys.modules