annotate Lib/test/test_syslog.py @ 87690:66c1c9f32567 default tip

Add use_weakref option to functools.lru_cache The use_weakref option makes lru_cache create weak references to the function arguments when creating the cache key, which prevents them from staying in the memory forever even after all other references to them are gone. This is a proof of concept for http://bugs.python.org/issue19859
author Radomir Dopieralski <devel@sheep.art.pl>
date Tue, 03 Dec 2013 16:02:48 +0100
parents 50d170bb71c7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
42810
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
1
52642
7347d916f13a Allow skipping of regression tests not supported on windows. This reduces noise in the regression test suite for py3k on Windows.
Kristján Valur Jónsson <kristjan@ccpgames.com>
parents: 47201
diff changeset
2 from test import support
7347d916f13a Allow skipping of regression tests not supported on windows. This reduces noise in the regression test suite for py3k on Windows.
Kristján Valur Jónsson <kristjan@ccpgames.com>
parents: 47201
diff changeset
3 syslog = support.import_module("syslog") #skip if not supported
42810
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
4 import unittest
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
5
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
6 # XXX(nnorwitz): This test sucks. I don't know of a platform independent way
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
7 # to verify that the messages were really logged.
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
8 # The only purpose of this test is to verify the code doesn't crash or leak.
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
9
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
10 class Test(unittest.TestCase):
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
11
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
12 def test_openlog(self):
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
13 syslog.openlog('python')
66799
50d170bb71c7 Issue #6697: Fixed instances of _PyUnicode_AsString() result not checked for NULL
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 52642
diff changeset
14 # Issue #6697.
50d170bb71c7 Issue #6697: Fixed instances of _PyUnicode_AsString() result not checked for NULL
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 52642
diff changeset
15 self.assertRaises(UnicodeEncodeError, syslog.openlog, '\uD800')
42810
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
16
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
17 def test_syslog(self):
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
18 syslog.openlog('python')
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
19 syslog.syslog('test message from python test_syslog')
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
20 syslog.syslog(syslog.LOG_ERR, 'test error from python test_syslog')
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
21
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
22 def test_closelog(self):
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
23 syslog.openlog('python')
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
24 syslog.closelog()
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
25
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
26 def test_setlogmask(self):
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
27 syslog.setlogmask(syslog.LOG_DEBUG)
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
28
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
29 def test_log_mask(self):
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
30 syslog.LOG_MASK(syslog.LOG_INFO)
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
31
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
32 def test_log_upto(self):
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
33 syslog.LOG_UPTO(syslog.LOG_INFO)
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
34
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
35 def test_main():
47201
9c930a32cebb #2621 rename test.test_support to test.support
Benjamin Peterson <benjamin@python.org>
parents: 42810
diff changeset
36 support.run_unittest(__name__)
42810
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
37
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
38 if __name__ == "__main__":
776b8bd68b30 Use unicode and add a "test" for syslog
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff changeset
39 test_main()