While testing PyCairo [1] on Mingw32, "ERROR collecting tests" was triggered [2]
Most of the errors are because the __file__ attribute of test files has backslashes as the directory separators beyond the test root directory, while it's expecting all forward slashes:
_________________ ERROR collecting tests/test_textextents.py __________________
import file mismatch:
imported module 'tests.test_textextents' has this __file__ attribute:
D:/a/1/s\tests\test_textextents.py
which is not the same as the test file we want to collect:
D:/a/1/s/tests/test_textextents.py
Longer log
##[section]Starting: Test
==============================================================================
Task : Command line
Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version : 2.151.2
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
========================== Starting Command Output ===========================
##[command]"C:\windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "d:\a\_temp\dcc6be11-cb7c-4f24-9554-70225cf9e5bf.cmd""
+ set -e
+ export MSYS2_FC_CACHE_SKIP=1
+ MSYS2_FC_CACHE_SKIP=1
+ export PYTHONPYCACHEPREFIX=/home/VssAdministrator/.cache/i686-python3/
+ PYTHONPYCACHEPREFIX=/home/VssAdministrator/.cache/i686-python3/
+ mkdir -p /home/VssAdministrator/.cache/i686-python3/
+ pacman --noconfirm -Suy
[snipped]
+ pacman --noconfirm -S --needed mingw-w64-i686-cairo mingw-w64-i686-python3 mingw-w64-i686-python3-pip mingw-w64-i686-toolchain git
[snipped]
============================= test session starts =============================
platform win32 -- Python 3.8.0, pytest-5.3.1, py-1.8.0, pluggy-0.13.1
rootdir: D:/a/1/s
plugins: hypothesis-4.50.6
collected 0 items / 18 errors / 2 skipped
[snipped]
=================================== ERRORS ====================================
_____________________ ERROR collecting tests/test_api.py ______________________
import file mismatch:
imported module 'tests.test_api' has this __file__ attribute:
D:/a/1/s\tests\test_api.py
which is not the same as the test file we want to collect:
D:/a/1/s/tests/test_api.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
[1] Pycairo on github
https://github.com/pygobject/pycairo
[2] Build log on Azure
https://dev.azure.com/pygobject/pycairo/_build/results?buildId=249
I got past this by setting PY_IGNORE_IMPORTMISMATCH=1 but I'm not sure that this error should be happening in the first place here ?
Hi @stuaxo, sorry for the delay.
Does it work if you clean up all .pyc files before running the test suite?
I tried setting a the bytecode cache directory to a unique name, and disabling bytecode creation which didn't help.
I'm not familiar enough with azure pipelines to know if things were cleared up, but fairly sure doing the above should have helped.
I thought it was a fresh VM for running the tests, but would need to poke it more to find out if this was actually the case.
i suspect its a difference in normalization between assertion rewriting and pylib py.path.local i cant investigate myself before the weekend, but we might want to investigate using pathlib + own code instead of pylibs import helper
Very likely... pathlib does a great job of comparing files correctly under the proper platform semantics.
additionally going away from the import helper of pylib will be a great asset in removing the hard dependency on pylib
I think this is mainly a MSYS2 bug, see https://github.com/msys2/MINGW-packages/issues/6035 I'll look into it (on the MSYS2 side) when I have some time.
Awesome I didn't realize you were involved on that end too.
May as well keep this open in the meantime in case anyone else hits the same issue + ends up on this bug tracker.
Fixed in msys2: https://github.com/msys2/MINGW-packages/pull/6062
Fixed version is deployed. This can be closed imo.
Most helpful comment
I think this is mainly a MSYS2 bug, see https://github.com/msys2/MINGW-packages/issues/6035 I'll look into it (on the MSYS2 side) when I have some time.