From 1e7feab8df1b710af63c8683c8f998cc4417ecfe Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Wed, 14 May 2025 15:08:00 +0100 Subject: [PATCH 1/2] Check for old-style importer --- tests/scripting_directory_tests.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/scripting_directory_tests.py b/tests/scripting_directory_tests.py index fecfe01..ca1ddd0 100644 --- a/tests/scripting_directory_tests.py +++ b/tests/scripting_directory_tests.py @@ -61,3 +61,18 @@ def test_GIVEN_that_instrument_scripts_directory_exists_THEN_it_does_not_contain self._directory_contains_compiled_files(self.inst_directory), "Instrument scripts directory contained compiled files", ) + + def test_GIVEN_inst_scripts_dir_exists_THEN_it_doesnt_contain_old_style_importer(self): + init = os.path.join(self.inst_directory, "__init__.py") + if not os.path.exists(init): + self.skipTest("No inst\\__init__.py found") + + with open(init) as f: + text = f.read() + + if "import pkgutil" in text: + self.fail( + "Instrument scripts directory contained old-style 'from * import *' code. " + "This doesn't work with Python 3.12, or with pyright. " + "It should be migrated to standard python imports." + ) From 956a4c3265a935fcbb9a9d9460e64c8619df5ea4 Mon Sep 17 00:00:00 2001 From: DavidKeymer Date: Mon, 19 May 2025 15:53:37 +0100 Subject: [PATCH 2/2] Edited path to python to run tests --- run_tests.bat | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/run_tests.bat b/run_tests.bat index 0e3f313..b5da131 100644 --- a/run_tests.bat +++ b/run_tests.bat @@ -4,6 +4,7 @@ REM Define working directories set "configs_dir=%~dp0configs" set "gui_dir=%~dp0gui" set "reports_dir=%~dp0test-reports" +set "python_dir=C:\Instrument\Apps\Python3" REM Clone necessary repositories REM Do this here rather than in python because it will make git authentication dialogs visible rather than being in a python thread. @@ -19,7 +20,7 @@ if exist "%reports_dir%" ( rd /s /q "%reports_dir%" ) -call %~dp0Python3\genie_python3.bat -u run_tests.py --configs_repo_path "%configs_dir%" --gui_repo_path "%gui_dir%" --reports_path "%reports_dir%" +call %python_dir%\genie_python3.bat -u run_tests.py --configs_repo_path "%configs_dir%" --gui_repo_path "%gui_dir%" --reports_path "%reports_dir%" if %errorlevel% neq 0 ( @echo ERROR: genie_python3.bat exited with code %errorlevel% exit /b %errorlevel%