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

Fix wrong fixture behavior due to cached fixtures and conftest not being watched #67

Merged
merged 34 commits into from
Dec 26, 2023

Conversation

JamesHutchison
Copy link
Owner

@JamesHutchison JamesHutchison commented Dec 24, 2023

This addresses #65

There are a couple issues around fixtures that this addresses.

  • Changes to fixture dependencies not reflected
  • Changes to fixture logic not reflected
  • Changes to fixtures used in a test not reflected

The fixture logic and dependencies not updating were observed as occurring due to conftest files not being watched. The automatic file watching applied to tests but not the conftest files used by tests. This adds automatic watching of conftest files, which can be disabled with PYTEST_DAEMON_DO_NOT_AUTOWATCH_FIXTURES / --daemon-do-not-autowatch-fixtures

The other issue was that the session caching was resulting in stale fixture references in test functions. This adds logic to clear the session cache if jurigged updates the signature of a test function.

Adds env variable - PYTEST_DAEMON_USE_WATCHMAN which determines whether to use watchman or polling for filesystem updates.

@JamesHutchison
Copy link
Owner Author

Randomly reproducing the CI issues so there appears to be more to it

@JamesHutchison
Copy link
Owner Author

JamesHutchison commented Dec 24, 2023

Running in a dev container, it usually passes

Running in the CI it seems to always fail

Adding delays and retries not mitigating issue on CI. Adding delays seemed to help on dev container but maybe it didn't. Retries not helping seems to imply that if its a race condition, things are getting "cemented".

Odd that jurigged acknowledges changes, test run indicates that its not using a cached session, but seeing the error when things were cached.

@JamesHutchison
Copy link
Owner Author

JamesHutchison commented Dec 26, 2023

Github CI must be using a cached network mount that results in signals working but stale file read data. Moving to temp directory (which won't use mount and should have predictable IO), which I contemplating doing originally, seems to have fixed the CI issue. It's not clear to me why errors showed the updated version of the function but even with excessive delays the hot reloader was still loading in a stale version.

@JamesHutchison JamesHutchison merged commit 16c4f2b into main Dec 26, 2023
3 checks passed
@JamesHutchison JamesHutchison deleted the fixtures-fixes branch December 26, 2023 21:10
@JamesHutchison
Copy link
Owner Author

Related to #16 because this adds the env variable PYTEST_DAEMON_USE_WATCHMAN

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

Successfully merging this pull request may close these issues.

1 participant