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

Method setUp

Lib/test/test_pathlib/test_pathlib.py:1139–1176  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1137 can_symlink = os_helper.can_symlink()
1138
1139 def setUp(self):
1140 name = self.id().split('.')[-1]
1141 if name in _tests_needing_symlinks and not self.can_symlink:
1142 self.skipTest('requires symlinks')
1143 super().setUp()
1144 os.mkdir(self.base)
1145 os.mkdir(os.path.join(self.base, 'dirA'))
1146 os.mkdir(os.path.join(self.base, 'dirB'))
1147 os.mkdir(os.path.join(self.base, 'dirC'))
1148 os.mkdir(os.path.join(self.base, 'dirC', 'dirD'))
1149 os.mkdir(os.path.join(self.base, 'dirE'))
1150 with open(os.path.join(self.base, 'fileA'), 'wb') as f:
1151 f.write(b"this is file A\n")
1152 with open(os.path.join(self.base, 'dirB', 'fileB'), 'wb') as f:
1153 f.write(b"this is file B\n")
1154 with open(os.path.join(self.base, 'dirC', 'fileC'), 'wb') as f:
1155 f.write(b"this is file C\n")
1156 with open(os.path.join(self.base, 'dirC', 'novel.txt'), 'wb') as f:
1157 f.write(b"this is a novel\n")
1158 with open(os.path.join(self.base, 'dirC', 'dirD', 'fileD'), 'wb') as f:
1159 f.write(b"this is file D\n")
1160 os.chmod(os.path.join(self.base, 'dirE'), 0)
1161 if self.can_symlink:
1162 # Relative symlinks.
1163 os.symlink('fileA', os.path.join(self.base, 'linkA'))
1164 os.symlink('non-existing', os.path.join(self.base, 'brokenLink'))
1165 os.symlink('dirB',
1166 os.path.join(self.base, 'linkB'),
1167 target_is_directory=True)
1168 os.symlink(os.path.join('..', 'dirB'),
1169 os.path.join(self.base, 'dirA', 'linkC'),
1170 target_is_directory=True)
1171 # This one goes upwards, creating a loop.
1172 os.symlink(os.path.join('..', 'dirB'),
1173 os.path.join(self.base, 'dirB', 'linkD'),
1174 target_is_directory=True)
1175 # Broken symlink (pointing to itself).
1176 os.symlink('brokenLinkLoop', os.path.join(self.base, 'brokenLinkLoop'))
1177
1178 def tearDown(self):
1179 os.chmod(os.path.join(self.base, 'dirE'), 0o777)

Callers

nothing calls this directly

Calls 9

superClass · 0.85
skipTestMethod · 0.80
openFunction · 0.50
splitMethod · 0.45
idMethod · 0.45
mkdirMethod · 0.45
joinMethod · 0.45
writeMethod · 0.45
chmodMethod · 0.45

Tested by

no test coverage detected