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

Method test_pathlike_objects

Lib/test/test_logging.py:676–696  ·  view source on GitHub ↗

Test that path-like objects are accepted as filename arguments to handlers. See Issue #27493.

(self)

Source from the content-addressed store, hash-verified

674 h.close()
675
676 def test_pathlike_objects(self):
677 """
678 Test that path-like objects are accepted as filename arguments to handlers.
679
680 See Issue #27493.
681 """
682 fn = make_temp_file()
683 os.unlink(fn)
684 pfn = os_helper.FakePath(fn)
685 cases = (
686 (logging.FileHandler, (pfn, 'w')),
687 (logging.handlers.RotatingFileHandler, (pfn, 'a')),
688 (logging.handlers.TimedRotatingFileHandler, (pfn, 'h')),
689 )
690 if sys.platform in ('linux', 'android', 'darwin'):
691 cases += ((logging.handlers.WatchedFileHandler, (pfn, 'w')),)
692 for cls, args in cases:
693 h = cls(*args, encoding="utf-8")
694 self.assertTrue(os.path.exists(fn))
695 h.close()
696 os.unlink(fn)
697
698 @unittest.skipIf(os.name == 'nt', 'WatchedFileHandler not appropriate for Windows.')
699 @threading_helper.requires_working_threading()

Callers

nothing calls this directly

Calls 6

make_temp_fileFunction · 0.85
assertTrueMethod · 0.80
clsClass · 0.50
unlinkMethod · 0.45
existsMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected