Test that path-like objects are accepted as filename arguments to handlers. See Issue #27493.
(self)
| 658 | h.close() |
| 659 | |
| 660 | def test_pathlike_objects(self): |
| 661 | """ |
| 662 | Test that path-like objects are accepted as filename arguments to handlers. |
| 663 | |
| 664 | See Issue #27493. |
| 665 | """ |
| 666 | fn = make_temp_file() |
| 667 | os.unlink(fn) |
| 668 | pfn = os_helper.FakePath(fn) |
| 669 | cases = ( |
| 670 | (logging.FileHandler, (pfn, 'w')), |
| 671 | (logging.handlers.RotatingFileHandler, (pfn, 'a')), |
| 672 | (logging.handlers.TimedRotatingFileHandler, (pfn, 'h')), |
| 673 | ) |
| 674 | if sys.platform in ('linux', 'android', 'darwin'): |
| 675 | cases += ((logging.handlers.WatchedFileHandler, (pfn, 'w')),) |
| 676 | for cls, args in cases: |
| 677 | h = cls(*args, encoding="utf-8") |
| 678 | self.assertTrue(os.path.exists(fn)) |
| 679 | h.close() |
| 680 | os.unlink(fn) |
| 681 | |
| 682 | @unittest.skipIf(os.name == 'nt', 'WatchedFileHandler not appropriate for Windows.') |
| 683 | @unittest.skipIf( |
nothing calls this directly
no test coverage detected