"ERROR collecting tests" - backslash vs forward slash on Mingw32
See original GitHub issueWhile 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
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
D113268 [clangd] Fix tests with forward slash as separator on ...
It sounds like this is the build option WINDOWS_PREFER_FORWARD_SLASH_DEFAULT, which is set for mingw builds (and could be set manually too). I ...
Read more >How to include forward slash "/" in pytest -k command line option
I tried backslash escaping it with one and two backslashes but still the same error. Any idea how to do this? ERROR: Wrong...
Read more >Sourcetree cannot handle backslash in URL of git r...
When I specify for the repository location in Repository Settings at URL/Path: \\\\BC01245\\myproject (which is a local shared folder on my computer.
Read more >MinGW - Minimalist GNU for Windows / Issues / #1789 stat function ...
3) The technique adopted is unsafe in multibyte character locales; it may incorrectly identify trailing slashes, or more likely trailing backslashes, ...
Read more >Changelog — Python 3.11.1 documentation
DataError exception type in case of too large strings and/or blobs passed. gh-98713: Fix a bug in the typing tests where a test...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
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