-
-
Notifications
You must be signed in to change notification settings - Fork 742
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
base: master
Are you sure you want to change the base?
Conversation
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.
follow_symlinks is also used in other places. perhaps I should change them? |
Codecov Report
❗ 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 |
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
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)