MCPcopy Index your code
hub / github.com/python/cpython / setUp

Method setUp

Lib/test/test_py_compile.py:55–72  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

53class PyCompileTestsBase:
54
55 def setUp(self):
56 self.directory = tempfile.mkdtemp(dir=os.getcwd())
57 self.source_path = os.path.join(self.directory, '_test.py')
58 self.pyc_path = self.source_path + 'c'
59 try:
60 self.cache_path = importlib.util.cache_from_source(self.source_path)
61 except NotImplementedError:
62 self.cache_path = None
63 self.cwd_drive = os.path.splitdrive(os.getcwd())[0]
64 # In these tests we compute relative paths. When using Windows, the
65 # current working directory path and the 'self.source_path' might be
66 # on different drives. Therefore we need to switch to the drive where
67 # the temporary source file lives.
68 drive = os.path.splitdrive(self.source_path)[0]
69 if drive:
70 os.chdir(drive)
71 with open(self.source_path, 'w') as file:
72 file.write('x = 123\n')
73
74 def tearDown(self):
75 shutil.rmtree(self.directory)

Callers

nothing calls this directly

Calls 4

mkdtempMethod · 0.80
openFunction · 0.50
joinMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected