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

Method test_change_cwd__chdir_warning

Lib/test/test_support.py:311–327  ·  view source on GitHub ↗

Check the warning message when os.chdir() fails.

(self)

Source from the content-addressed store, hash-verified

309 # Tests for change_cwd()
310
311 def test_change_cwd__chdir_warning(self):
312 """Check the warning message when os.chdir() fails."""
313 path = TESTFN + '_does_not_exist'
314 with warnings_helper.check_warnings() as recorder, _caplog() as caplog:
315 with os_helper.change_cwd(path=path, quiet=True):
316 pass
317 messages = [str(w.message) for w in recorder.warnings]
318
319 self.assertListEqual(messages, [])
320 self.assertEqual(len(caplog.records), 1)
321 record = caplog.records[0]
322 self.assertStartsWith(
323 record.getMessage(),
324 f'tests may fail, unable to change '
325 f'the current working directory '
326 f'to {path!r}: ',
327 )
328
329 # Tests for temp_cwd()
330

Callers

nothing calls this directly

Calls 7

_caplogFunction · 0.85
strFunction · 0.85
lenFunction · 0.85
assertListEqualMethod · 0.80
assertEqualMethod · 0.45
assertStartsWithMethod · 0.45
getMessageMethod · 0.45

Tested by

no test coverage detected