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

Support scrubbing absolute temporary paths in test_html.py on Windows #1771

Merged
merged 2 commits into from
Apr 29, 2024

Conversation

devdanzin
Copy link
Contributor

Some gold files, like tests/gold/html/other/index.html record an absolute path that includes the temporary directory used while testing, like:

/private/var/folders/6j/khn0mcrj35d1k3yylpl8zl080000gn/T/pytest-of-ned/pytest-293/t40/othersrc/other.py

There's explicit support for the directory format above in the regex:

/private/var/[\w/]+/pytest-of-\w+/pytest-\d+/(popen-gw\d+/)?t\d+

However, when creating the gold files on Windows, the absolute path takes a rather different format, for example:

C:\Users\ddini\AppData\Local\Temp\pytest-of-ddini\pytest-9\popen-gw6\t1\othersrc\other.py

This PR adds a new regex to match and scrub directories in the format above:

[A-Z]:\\Users\\[\w\\]+\\pytest-of-\w+\\pytest-\d+\\(popen-gw\d+\\)?t\d+

@nedbat
Copy link
Owner

nedbat commented Apr 28, 2024

This looks reasonable on the face of it, but we run the test suite on Windows on GitHub Actions all the time, and this hasn't been needed there. Do you know why?

@devdanzin
Copy link
Contributor Author

Yes, it's because running the tests on Windows works due to compare_html successfully scrubbing the path of the TEST_TMPDIR of the generated HTML file. It's handled by the filepath_to_regex(abs_file(os.getcwd())) scrub rule.

However, the TEST_TMPDIR that gets recorded in a gold file doesn't get handled by the above scrub rule. That's why there is a scrub rule for recorded paths in test_html:

(r'/private/var/[\w/]+/pytest-of-\w+/pytest-\d+/(popen-gw\d+/)?t\d+', 'TEST_TMPDIR'),

It handles the current recorded value, but won't work for paths recorded on Windows. So merely running the tests on Windows works, updating the gold files on Windows doesn't.

@nedbat nedbat merged commit 0ae5775 into nedbat:master Apr 29, 2024
35 checks passed
@devdanzin devdanzin deleted the support_gold_in_windows branch April 30, 2024 00:08
@devdanzin devdanzin restored the support_gold_in_windows branch April 30, 2024 09:14
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.

None yet

2 participants