Skip to content

bpo-46425: fix direct invocation of test_contextlib #30681

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

Merged
merged 2 commits into from
Jan 21, 2022

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Jan 19, 2022

There was a problem with direct invocation of test_contextlib. The best way to illustrate it is:

» ./python.exe Lib/test/test_contextlib.py
...................................................................................
----------------------------------------------------------------------
Ran 83 tests in 0.046s

OK

But, when a path starts with ./, we have a problem:

» ./python.exe ./Lib/test/test_contextlib.py
............................FFF....................................................
======================================================================
FAIL: test_exception (__main__.TestChdir)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/./Lib/test/test_contextlib.py", line 1159, in test_exception
    self.assertEqual(os.getcwd(), target)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '/Users/sobolev/Desktop/cpython/Lib/test/data' != '/Users/sobolev/Desktop/cpython/./Lib/test/data'
- /Users/sobolev/Desktop/cpython/Lib/test/data
+ /Users/sobolev/Desktop/cpython/./Lib/test/data
?                                ++


======================================================================
FAIL: test_reentrant (__main__.TestChdir)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/./Lib/test/test_contextlib.py", line 1143, in test_reentrant
    self.assertEqual(os.getcwd(), target1)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '/Users/sobolev/Desktop/cpython/Lib/test/data' != '/Users/sobolev/Desktop/cpython/./Lib/test/data'
- /Users/sobolev/Desktop/cpython/Lib/test/data
+ /Users/sobolev/Desktop/cpython/./Lib/test/data
?                                ++


======================================================================
FAIL: test_simple (__main__.TestChdir)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/./Lib/test/test_contextlib.py", line 1132, in test_simple
    self.assertEqual(os.getcwd(), target)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '/Users/sobolev/Desktop/cpython/Lib/test/data' != '/Users/sobolev/Desktop/cpython/./Lib/test/data'
- /Users/sobolev/Desktop/cpython/Lib/test/data
+ /Users/sobolev/Desktop/cpython/./Lib/test/data
?                                ++


----------------------------------------------------------------------
Ran 83 tests in 0.050s

FAILED (failures=3)

When __file__ is normalized - the error is gone. Now we can use both styles to call this module.

https://bugs.python.org/issue46425

CC @corona10 as my mentor.

@miss-islington
Copy link
Contributor

Thanks @sobolevn for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry, @sobolevn and @serhiy-storchaka, I could not cleanly backport this to 3.10 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 22f73bd9f1fc573d5c998f345b66c29f7ca6614d 3.10

@miss-islington
Copy link
Contributor

Sorry @sobolevn and @serhiy-storchaka, I had trouble checking out the 3.9 backport branch.
Please backport using cherry_picker on command line.
cherry_picker 22f73bd9f1fc573d5c998f345b66c29f7ca6614d 3.9

@serhiy-storchaka serhiy-storchaka removed needs backport to 3.9 only security fixes needs backport to 3.10 only security fixes labels Jan 21, 2022
@serhiy-storchaka serhiy-storchaka removed their assignment Jan 21, 2022
@sobolevn
Copy link
Member Author

Thank you, @serhiy-storchaka! I will backport them manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants