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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions Lib/test/test_contextlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1117,9 +1117,15 @@ def test_cm_is_reentrant(self):


class TestChdir(unittest.TestCase):
def make_relative_path(self, *parts):
return os.path.join(
os.path.dirname(os.path.normpath(__file__)),
*parts,
)

def test_simple(self):
old_cwd = os.getcwd()
target = os.path.join(os.path.dirname(__file__), 'data')
target = self.make_relative_path('data')
self.assertNotEqual(old_cwd, target)

with chdir(target):
Expand All @@ -1128,8 +1134,8 @@ def test_simple(self):

def test_reentrant(self):
old_cwd = os.getcwd()
target1 = os.path.join(os.path.dirname(__file__), 'data')
target2 = os.path.join(os.path.dirname(__file__), 'ziptestdata')
target1 = self.make_relative_path('data')
target2 = self.make_relative_path('ziptestdata')
self.assertNotIn(old_cwd, (target1, target2))
chdir1, chdir2 = chdir(target1), chdir(target2)

Expand All @@ -1145,7 +1151,7 @@ def test_reentrant(self):

def test_exception(self):
old_cwd = os.getcwd()
target = os.path.join(os.path.dirname(__file__), 'data')
target = self.make_relative_path('data')
self.assertNotEqual(old_cwd, target)

try:
Expand Down