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

testsuite: only use follow_symlinks if supported #7754

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RayyanAnsari
Copy link
Contributor

@RayyanAnsari RayyanAnsari commented Aug 1, 2023

On Windows, follow_symlinks is not supported by every os function yet, using False can raise a NotImplementedError. Check os.supports_follow_symlinks to decide whether to use True or False.

(this should fix the utime tests that were being skipped before)

On Windows, follow_symlinks is not supported by every os function yet, using False can raise a NotImplementedError.
Check os.supports_follow_symlinks to decide whether to use True or False.
@RayyanAnsari
Copy link
Contributor Author

follow_symlinks is also used in other places. perhaps I should change them?

@codecov-commenter
Copy link

codecov-commenter commented Aug 1, 2023

Codecov Report

Merging #7754 (32813e5) into master (1c8da8f) will decrease coverage by 0.02%.
The diff coverage is n/a.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master    #7754      +/-   ##
==========================================
- Coverage   83.70%   83.68%   -0.02%     
==========================================
  Files          66       66              
  Lines       11906    11906              
  Branches     2158     2158              
==========================================
- Hits         9966     9964       -2     
- Misses       1366     1367       +1     
- Partials      574      575       +1     

see 1 file with indirect coverage changes

Comment on lines 149 to +151
try:
os.utime(filepath, (1000, 2000), follow_symlinks=False)
new_stats = os.stat(filepath, follow_symlinks=False)
os.utime(filepath, (1000, 2000), follow_symlinks=False if os.utime in os.supports_follow_symlinks else True)
new_stats = os.stat(filepath, follow_symlinks=False if os.stat in os.supports_follow_symlinks else True)
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, guess that needs to be done differently:
The code right above either creates a symlink (with a non-existing target as it seems) or a file.
So we can't just arbitrarily switch follow_symlinks to True/False below:

  • the target does not exist
  • also, line 144 seems to imply we want to know about utime behaviour on symlinks

So guess this needs double-checking:

  • what tests do use this and what exactly do we need to check here?
  • the utime call needs to match the fs object it is used with

Copy link
Member

@ThomasWaldmann ThomasWaldmann Aug 2, 2023

Choose a reason for hiding this comment

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

Also: never use a condition to decide between True or False. Above, you could've just used follow_symlinks=os.stat not in os.supports_follow_symlinks.

Reads a bit strange, but guess that's because the default (and always supported) behaviour is with True and the special (and sometimes unsupported) behaviour is with False.

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.

3 participants