Fix integration test failures caused by sys.modules pollution and shutil.SameFileError#349
Fix integration test failures caused by sys.modules pollution and shutil.SameFileError#349
Conversation
…FileError, update CI workflow Co-authored-by: t0mdavid-m <57191390+t0mdavid-m@users.noreply.github.com>
|
@copilot Why do we need mocks here? |
…, simplify test_parameter_presets.py Co-authored-by: t0mdavid-m <57191390+t0mdavid-m@users.noreply.github.com>
The pyopenms mock in In |
|
@copilot fix the error in the windows build |
Co-authored-by: t0mdavid-m <57191390+t0mdavid-m@users.noreply.github.com>
The "Clean up unnecessary Python files" step in |
Two test files were replacing
sys.modules['streamlit']andsys.modules['pyopenms']with MagicMocks at module level, causing pytest to poison the global module registry during collection — before any tests ran. This broke alltest_gui.pyAppTest runs withModuleNotFoundError: No module named 'streamlit.emojis'; 'streamlit' is not a package. A separateshutil.SameFileErrorcaused test failures when symlinks created bytest_file_upload_load_examplewere re-copied in subsequent tests.Changes
tests/test_parameter_presets.py— Removed the unnecessarypyopenmsmock. Thestreamlitmock is still needed becauseParameterManagerimportsstreamlitat the top level and the tests needst.session_stateto be a controllable plain dict for unit testing preset logic without a running Streamlit app context. The mock is now saved and restored immediately after importingParameterManager, and cachedsrc.workflow.*entries are evicted so AppTest re-imports them with the real package:tests/test_topp_workflow_parameter.py— Removed all module-level mocks entirely. The tests use pureMagicMockobjects and don't import anysrc.*modules, so thepyopenmsmock served no purpose. Also removed thetest_mock_pyopenmstest that only verified the mock was working.test_gui.py— Catchshutil.SameFileErrorwhen copying example mzML files into the workspace. On Linux,load_example_mzML_files()creates symlinks pointing back to the same source files, so a subsequentshutil.copyraisesSameFileError:.github/workflows/ci.yml— Replaceconda-incubator/setup-miniconda+conda install openmswithactions/setup-python@v4.pyopenmsis already a standalone PyPI package inrequirements.txt; the conda layer was redundant and conflicted with the pip-installed streamlit..github/workflows/build-windows-executable-app.yaml— Fix the "Clean up unnecessary Python files" step which used a hardcoded wrong pathpy/Lib/site-packagesinstead ofpython-${{ env.PYTHON_VERSION }}/Lib/site-packages, matching the path used by the "Install Required Packages" step.Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.