MCPcopy Index your code
hub / github.com/RustPython/RustPython / setUp

Method setUp

Lib/test/test_py_compile.py:55–69  ·  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 self.cache_path = importlib.util.cache_from_source(self.source_path)
60 self.cwd_drive = os.path.splitdrive(os.getcwd())[0]
61 # In these tests we compute relative paths. When using Windows, the
62 # current working directory path and the 'self.source_path' might be
63 # on different drives. Therefore we need to switch to the drive where
64 # the temporary source file lives.
65 drive = os.path.splitdrive(self.source_path)[0]
66 if drive:
67 os.chdir(drive)
68 with open(self.source_path, 'w') as file:
69 file.write('x = 123\n')
70
71 def tearDown(self):
72 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