Created
December 5, 2021 23:33
-
-
Save tos-kamiya/7922dd022ecbed9d4c9c2081f5734b33 to your computer and use it in GitHub Desktop.
fix: os.chdir in unittest's test case causes a RecursionError on Windows 10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import * | |
import os | |
import tempfile | |
import unittest | |
class ChdirTest(unittest.TestCase): | |
def test_chdir(self): | |
with tempfile.TemporaryDirectory() as tempdir: | |
curdir = os.getcwd() | |
try: | |
os.chdir(tempdir) | |
print("the current dir is: %s" % tempdir) | |
finally: | |
os.chdir(curdir) | |
if __name__ == "__main__": | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment