diff options
author | Brett Cannon <brett@python.org> | 2012-04-26 00:18:24 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2012-04-26 00:18:24 (GMT) |
commit | 5a5d6a10333af38c753b82f8d1bef14906c12b61 (patch) | |
tree | 9bc3c6d28e29f08646775fec90e8b5000a633f02 /Lib | |
parent | 8923a4d4c514a621b7f99ee0f3ebdde319aee0e9 (diff) | |
parent | 718fbf078cef405318dc712a2c32fbc12e87de02 (diff) | |
download | cpython-5a5d6a10333af38c753b82f8d1bef14906c12b61.zip cpython-5a5d6a10333af38c753b82f8d1bef14906c12b61.tar.gz cpython-5a5d6a10333af38c753b82f8d1bef14906c12b61.tar.bz2 |
Merge
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/importlib/_bootstrap.py | 7 | ||||
-rw-r--r-- | Lib/test/test_logging.py | 34 | ||||
-rw-r--r-- | Lib/unittest/case.py | 2 | ||||
-rw-r--r-- | Lib/unittest/test/test_skipping.py | 15 |
4 files changed, 40 insertions, 18 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index 817fe39..47ccd41 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -6,6 +6,13 @@ such it requires the injection of specific modules and attributes in order to work. One should use importlib as the public-facing version of this module. """ +# +# IMPORTANT: Whenever making changes to this module, be sure to run +# a top-level make in order to get the frozen version of the module +# update. Not doing so, will result in the Makefile to fail for +# all others who don't have a ./python around to freeze the module +# in the early stages of compilation. +# # See importlib._setup() for what is injected into the global namespace. diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index ee1c211..2279952 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -593,28 +593,28 @@ class HandlerTest(BaseTest): pass time.sleep(0.004 * random.randint(0, 4)) - def cleanup(remover, fn, handler): - handler.close() - remover.join() - if os.path.exists(fn): - os.unlink(fn) + del_count = 500 + log_count = 500 - fd, fn = tempfile.mkstemp('.log', 'test_logging-3-') - os.close(fd) - del_count = 1000 - log_count = 1000 - remover = threading.Thread(target=remove_loop, args=(fn, del_count)) - remover.daemon = True - remover.start() for delay in (False, True): + fd, fn = tempfile.mkstemp('.log', 'test_logging-3-') + os.close(fd) + remover = threading.Thread(target=remove_loop, args=(fn, del_count)) + remover.daemon = True + remover.start() h = logging.handlers.WatchedFileHandler(fn, delay=delay) - self.addCleanup(cleanup, remover, fn, h) f = logging.Formatter('%(asctime)s: %(levelname)s: %(message)s') h.setFormatter(f) - for _ in range(log_count): - time.sleep(0.005) - r = logging.makeLogRecord({'msg': 'testing' }) - h.handle(r) + try: + for _ in range(log_count): + time.sleep(0.005) + r = logging.makeLogRecord({'msg': 'testing' }) + h.handle(r) + finally: + h.close() + remover.join() + if os.path.exists(fn): + os.unlink(fn) class BadStream(object): diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py index 5bed868..28f0a2d 100644 --- a/Lib/unittest/case.py +++ b/Lib/unittest/case.py @@ -61,7 +61,7 @@ def skip(reason): Unconditionally skip a test. """ def decorator(test_item): - if not (isinstance(test_item, type) and issubclass(test_item, TestCase)): + if not isinstance(test_item, type): @functools.wraps(test_item) def skip_wrapper(*args, **kwargs): raise SkipTest(reason) diff --git a/Lib/unittest/test/test_skipping.py b/Lib/unittest/test/test_skipping.py index b592464..952240e 100644 --- a/Lib/unittest/test/test_skipping.py +++ b/Lib/unittest/test/test_skipping.py @@ -66,6 +66,21 @@ class Test_TestSkipping(unittest.TestCase): self.assertEqual(result.skipped, [(test, "testing")]) self.assertEqual(record, []) + def test_skip_non_unittest_class(self): + @unittest.skip("testing") + class Mixin: + def test_1(self): + record.append(1) + class Foo(Mixin, unittest.TestCase): + pass + record = [] + result = unittest.TestResult() + test = Foo("test_1") + suite = unittest.TestSuite([test]) + suite.run(result) + self.assertEqual(result.skipped, [(test, "testing")]) + self.assertEqual(record, []) + def test_expected_failure(self): class Foo(unittest.TestCase): @unittest.expectedFailure |