Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: Collection fails and breaks DB #169

Closed
robertschweizer opened this issue Sep 9, 2021 · 2 comments
Closed

Windows: Collection fails and breaks DB #169

robertschweizer opened this issue Sep 9, 2021 · 2 comments
Assignees

Comments

@robertschweizer
Copy link

On Windows, when I have source and test files in separate subfolders, testmon does not rerun tests correctly after I changed files. If I run it again, testmon creates a completely new DB file.

Console output:

pytest --testmon
============================= test session starts =============================
platform win32 -- Python 3.8.10, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
testmon: new DB, environment: default
rootdir: C:\Users\kftf964\playground\testmon\test_dir
plugins: testmon-1.2.0
collected 1 item

tests\test_script.py .                                                   [100%]

============================== 1 passed in 0.14s ==============================

# Change code
printf "def fun():\n    print('b')" > source/script.py

pytest --testmon || echo "non-zero exit-code"
============================= test session starts =============================
platform win32 -- Python 3.8.10, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
testmon: changed files: tests/test_script.py, skipping collection of 2 files, environment: default
rootdir: C:\Users\kftf964\playground\testmon\test_dir
plugins: testmon-1.2.0
collected 0 items

============================ no tests ran in 0.04s ============================
non-zero exit-code
pytest --testmon
============================= test session starts =============================
platform win32 -- Python 3.8.10, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
testmon: new DB, environment: default
rootdir: C:\Users\kftf964\playground\testmon\test_dir
plugins: testmon-1.2.0
collected 1 item

tests\test_script.py .                                                   [100%]

============================== 1 passed in 0.20s ==============================

Windows users with Git bash installed can use this shell script to reproduce:

# Configure to see all output
set -o verbose
set -e

# Set up project
mkdir source
touch source/__init__.py
printf "def fun():\n    print('a')" > source/script.py
mkdir tests
touch tests/__init__.py
printf "from source.script import fun\n\ndef test_fun():\n    fun()" > tests/test_script.py
pip install -U pytest pytest-testmon==1.2.0

# First run, tests are executed
pytest --testmon

# Change code
printf "def fun():\n    print('b')" > source/script.py

# No tests are executed the first time
pytest --testmon || echo "non-zero exit-code"

# Tests are executed
pytest --testmon

It works fine on a Docker image that I tried, so I suspect the issue is related e.g. to Windows paths using backslashes.

@tarpas tarpas self-assigned this Sep 10, 2021
@tarpas
Copy link
Owner

tarpas commented Nov 10, 2022

@robertschweizer https://stackoverflow.com/questions/31519880/windows-compatible-filesystems-file-time-resolutions says that FAT16 and FAT32 filesystems have 2s file modification time resolution. Are you using FAT? Does your bash git script reproduce the error if you insert 2s delay after first pytest run? ( @secult )

@tarpas
Copy link
Owner

tarpas commented Nov 11, 2022

@robertschweizer https://stackoverflow.com/questions/31519880/windows-compatible-filesystems-file-time-resolutions says that FAT16 and FAT32 filesystems have 2s file modification time resolution. Are you using FAT? Does your bash git script reproduce the error if you insert 2s delay after first pytest run? ( @secult )

@robertschweizer @secult ignore that, I realized the problem is something else.

tarpas added a commit that referenced this issue Nov 17, 2022
@tarpas tarpas closed this as completed Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants