Skip to content

Instantly share code, notes, and snippets.

@tos-kamiya
Last active December 5, 2021 23:24
Show Gist options
  • Save tos-kamiya/5c79ef72572562775fd3773b5cc217c4 to your computer and use it in GitHub Desktop.
Save tos-kamiya/5c79ef72572562775fd3773b5cc217c4 to your computer and use it in GitHub Desktop.
os.chdir in unittest's test case causes a RecursionError on Windows 10
import unittest
import os
import tempfile
class ChdirTest(unittest.TestCase):
def test_chdir(self):
with tempfile.TemporaryDirectory() as tempdir:
os.chdir(tempdir) # this results in remvoing the current directory, so causes an error on Windows
if __name__ == "__main__":
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment