Skip to content

chore(tests): do not use hard-coded paths in tests - #1834

Merged
mayeut merged 2 commits into
pypa:mainfrom
mayeut:use-tmp_path-for-tests
May 26, 2024
Merged

mayeut merged 2 commits into
pypa:mainfrom
mayeut:use-tmp_path-for-tests

Conversation

@mayeut

@mayeut mayeut commented May 25, 2024 •

Copy link
Copy Markdown
Member

This would help reduce the amount of specific code for pyodide in #1456

@mayeut mayeut mentioned this pull request May 25, 2024
5 of 8 tasks
@mayeut
mayeut marked this pull request as draft May 25, 2024 17:42
@mayeut mayeut changed the title chore(tests): do not use hard-coded paths in test_before_test chore(tests): do not use hard-coded paths in tests May 25, 2024
@mayeut
mayeut force-pushed the use-tmp_path-for-tests branch from a0166d4 to 1e9be73 Compare May 25, 2024 18:50
@mayeut
mayeut marked this pull request as ready for review May 25, 2024 21:20
@mayeut
mayeut requested a review from henryiii May 26, 2024 07:08
@mayeut

mayeut commented May 26, 2024

Copy link
Copy Markdown
Member Author

@henryiii, would you mind reviewing this one ?

I don't mind waiting for pyodide PR to land first but I'd rather have it the other way around though (and I'm willing to fix conflicts there if it helps).

Comment thread test/test_before_build.py Outdated

# TODO: This is not valid in an virtual environment
assert stored_path == current_path, '{0} != {1}'.format(stored_path, current_path)
assert os.stat(stored_prefix) == os.stat(sys.prefix)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not os.path.samefile?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also at least one more existing os.stat compare that would read better this way, imo. But could be a follow up because this matches the existing one(s).

@mayeut mayeut May 26, 2024 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check was already used in test_before_test.py so I reused it here.
I will change them for samefile which seems better suited.

use `os.path.samefile` rather than comparing `os.stat` directly.
@mayeut
mayeut merged commit 67ee9dd into pypa:main May 26, 2024
@mayeut
mayeut deleted the use-tmp_path-for-tests branch May 26, 2024 10:42
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.

2 participants