(self)
| 621 | self.assertRaises(NotImplementedError, h.emit, None) |
| 622 | |
| 623 | def test_builtin_handlers(self): |
| 624 | # We can't actually *use* too many handlers in the tests, |
| 625 | # but we can try instantiating them with various options |
| 626 | if sys.platform in ('linux', 'android', 'darwin'): |
| 627 | for existing in (True, False): |
| 628 | fn = make_temp_file() |
| 629 | if not existing: |
| 630 | os.unlink(fn) |
| 631 | h = logging.handlers.WatchedFileHandler(fn, encoding='utf-8', delay=True) |
| 632 | if existing: |
| 633 | dev, ino = h.dev, h.ino |
| 634 | self.assertEqual(dev, -1) |
| 635 | self.assertEqual(ino, -1) |
| 636 | r = logging.makeLogRecord({'msg': 'Test'}) |
| 637 | h.handle(r) |
| 638 | # Now remove the file. |
| 639 | os.unlink(fn) |
| 640 | self.assertFalse(os.path.exists(fn)) |
| 641 | # The next call should recreate the file. |
| 642 | h.handle(r) |
| 643 | self.assertTrue(os.path.exists(fn)) |
| 644 | else: |
| 645 | self.assertEqual(h.dev, -1) |
| 646 | self.assertEqual(h.ino, -1) |
| 647 | h.close() |
| 648 | if existing: |
| 649 | os.unlink(fn) |
| 650 | if sys.platform == 'darwin': |
| 651 | sockname = '/var/run/syslog' |
| 652 | else: |
| 653 | sockname = '/dev/log' |
| 654 | try: |
| 655 | h = logging.handlers.SysLogHandler(sockname) |
| 656 | self.assertEqual(h.facility, h.LOG_USER) |
| 657 | self.assertTrue(h.unixsocket) |
| 658 | h.close() |
| 659 | except OSError: # syslogd might not be available |
| 660 | pass |
| 661 | for method in ('GET', 'POST', 'PUT'): |
| 662 | if method == 'PUT': |
| 663 | self.assertRaises(ValueError, logging.handlers.HTTPHandler, |
| 664 | 'localhost', '/log', method) |
| 665 | else: |
| 666 | h = logging.handlers.HTTPHandler('localhost', '/log', method) |
| 667 | h.close() |
| 668 | h = logging.handlers.BufferingHandler(0) |
| 669 | r = logging.makeLogRecord({}) |
| 670 | self.assertTrue(h.shouldFlush(r)) |
| 671 | h.close() |
| 672 | h = logging.handlers.BufferingHandler(1) |
| 673 | self.assertFalse(h.shouldFlush(r)) |
| 674 | h.close() |
| 675 | |
| 676 | def test_pathlike_objects(self): |
| 677 | """ |
nothing calls this directly
no test coverage detected