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

Method test_change_cwd__chdir_warning

Lib/test/test_support.py:320–336  ·  view source on GitHub ↗

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

(self)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected