Test that path-like objects are accepted as filename arguments to handlers. See Issue #27493.
(self)
| 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() |
nothing calls this directly
no test coverage detected