Hello community, here is the log from the commit of package python3-unittest2 for openSUSE:Factory checked in at 2015-07-02 22:50:10 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python3-unittest2 (Old) and /work/SRC/openSUSE:Factory/.python3-unittest2.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "python3-unittest2" Changes: -------- --- /work/SRC/openSUSE:Factory/python3-unittest2/python3-unittest2.changes 2015-03-19 21:12:59.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.python3-unittest2.new/python3-unittest2.changes 2015-07-03 00:19:02.000000000 +0200 @@ -1,0 +2,15 @@ +Tue Jun 30 22:27:52 UTC 2015 - arun@gmx.de + +- update to version 1.1.0: + * Issue #15836: assertRaises(), assertRaisesRegex(), assertWarns() + and assertWarnsRegex() assertments now check the type of the first + argument to prevent possible user error. Based on patch by Daniel + Wagner-Hall. + * Issue #24134: assertRaises(), assertRaisesRegex(), assertWarns() + and assertWarnsRegex() checks now emits a deprecation warning when + callable is None or keyword arguments except msg is passed in the + context manager mode. + * Issue #22903: The fake test case created by unittest.loader when + it fails importing a test module is now picklable. + +------------------------------------------------------------------- Old: ---- unittest2-1.0.1.tar.gz New: ---- unittest2-1.1.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python3-unittest2.spec ++++++ --- /var/tmp/diff_new_pack.cF2cGb/_old 2015-07-03 00:19:02.000000000 +0200 +++ /var/tmp/diff_new_pack.cF2cGb/_new 2015-07-03 00:19:02.000000000 +0200 @@ -17,7 +17,7 @@ Name: python3-unittest2 -Version: 1.0.1 +Version: 1.1.0 Release: 0 Url: http://pypi.python.org/pypi/unittest2 Summary: The new features in unittest for Python 2.7 backported to Python 2.3+ ++++++ unittest2-1.0.1.tar.gz -> unittest2-1.1.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/unittest2-1.0.1/PKG-INFO new/unittest2-1.1.0/PKG-INFO --- old/unittest2-1.0.1/PKG-INFO 2015-03-12 03:56:02.000000000 +0100 +++ new/unittest2-1.1.0/PKG-INFO 2015-06-30 08:48:20.000000000 +0200 @@ -1,10 +1,10 @@ Metadata-Version: 1.1 Name: unittest2 -Version: 1.0.1 +Version: 1.1.0 Summary: The new features in unittest backported to Python 2.4+. Home-page: http://pypi.python.org/pypi/unittest2 -Author: Michael Foord -Author-email: michael@voidspace.org.uk +Author: Robert Collins +Author-email: rbtcollins@hp.com License: UNKNOWN Description: unittest2 is a backport of the new features added to the unittest testing framework in Python 2.7 and onwards. It is tested to run on Python 2.6, 2.7, @@ -175,6 +175,21 @@ CHANGELOG ========= + 2015-06-20 - 1.1.0 + ------------------ + + - Issue #15836: assertRaises(), assertRaisesRegex(), assertWarns() and + assertWarnsRegex() assertments now check the type of the first argument + to prevent possible user error. Based on patch by Daniel Wagner-Hall. + + - Issue #24134: assertRaises(), assertRaisesRegex(), assertWarns() and + assertWarnsRegex() checks now emits a deprecation warning when callable is + None or keyword arguments except msg is passed in the context manager mode. + + - Issue #22903: The fake test case created by unittest.loader when it fails + importing a test module is now picklable. + + 2015-03-12 - 1.0.1 ------------------ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/unittest2-1.0.1/README.txt new/unittest2-1.1.0/README.txt --- old/unittest2-1.0.1/README.txt 2015-03-12 03:55:04.000000000 +0100 +++ new/unittest2-1.1.0/README.txt 2015-06-30 05:20:46.000000000 +0200 @@ -167,6 +167,21 @@ CHANGELOG ========= +2015-06-20 - 1.1.0 +------------------ + +- Issue #15836: assertRaises(), assertRaisesRegex(), assertWarns() and + assertWarnsRegex() assertments now check the type of the first argument + to prevent possible user error. Based on patch by Daniel Wagner-Hall. + +- Issue #24134: assertRaises(), assertRaisesRegex(), assertWarns() and + assertWarnsRegex() checks now emits a deprecation warning when callable is + None or keyword arguments except msg is passed in the context manager mode. + +- Issue #22903: The fake test case created by unittest.loader when it fails + importing a test module is now picklable. + + 2015-03-12 - 1.0.1 ------------------ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/unittest2-1.0.1/setup.py new/unittest2-1.1.0/setup.py --- old/unittest2-1.0.1/setup.py 2015-03-12 03:53:46.000000000 +0100 +++ new/unittest2-1.1.0/setup.py 2015-06-30 08:47:44.000000000 +0200 @@ -48,9 +48,9 @@ 'Topic :: Software Development :: Testing', ] -AUTHOR = 'Michael Foord' +AUTHOR = 'Robert Collins' -AUTHOR_EMAIL = 'michael@voidspace.org.uk' +AUTHOR_EMAIL = 'rbtcollins@hp.com' KEYWORDS = "unittest testing tests".split(' ') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/unittest2-1.0.1/unittest2/__init__.py new/unittest2-1.1.0/unittest2/__init__.py --- old/unittest2-1.0.1/unittest2/__init__.py 2015-03-12 03:55:19.000000000 +0100 +++ new/unittest2-1.1.0/unittest2/__init__.py 2015-06-30 08:47:26.000000000 +0200 @@ -31,7 +31,7 @@ 'defaultTestLoader', 'SkipTest', 'skip', 'skipIf', 'skipUnless', 'expectedFailure', 'TextTestResult', '__version__', 'collector'] -__version__ = '1.0.1' +__version__ = '1.1.0' # Expose obsolete functions for backwards compatibility __all__.extend(['getTestCaseNames', 'makeSuite', 'findTestCases']) @@ -75,13 +75,3 @@ return loader.discover(start_dir=this_dir, pattern=pattern) __unittest = True - -def load_tests(loader, tests, pattern): - # All our tests are in test/ - the test objects found in unittest2 itself - # are base classes not intended to be executed. This load_tests intercepts - # discovery to prevent that. - import unittest2.test - result = loader.suiteClass() - for path in unittest2.test.__path__: - result.addTests(loader.discover(path, pattern=pattern)) - return result diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/unittest2-1.0.1/unittest2/case.py new/unittest2-1.1.0/unittest2/case.py --- old/unittest2-1.0.1/unittest2/case.py 2014-10-30 21:57:36.000000000 +0100 +++ new/unittest2-1.1.0/unittest2/case.py 2015-06-30 08:17:28.000000000 +0200 @@ -7,7 +7,7 @@ import logging import pprint import re -import traceback +import traceback2 as traceback import types import unittest import warnings @@ -135,6 +135,10 @@ test_item.__unittest_expecting_failure__ = True return test_item +def _is_subtype(expected, basetype): + if isinstance(expected, tuple): + return all(_is_subtype(e, basetype) for e in expected) + return isinstance(expected, type) and issubclass(expected, basetype) class _BaseTestCaseContext: @@ -148,32 +152,44 @@ class _AssertRaisesBaseContext(_BaseTestCaseContext): - def __init__(self, expected, test_case, callable_obj=None, - expected_regex=None): + def __init__(self, expected, test_case, expected_regex=None): _BaseTestCaseContext.__init__(self, test_case) self.expected = expected self.failureException = test_case.failureException - if callable_obj is not None: - try: - self.obj_name = callable_obj.__name__ - except AttributeError: - self.obj_name = str(callable_obj) - else: - self.obj_name = None if expected_regex is not None: expected_regex = re.compile(expected_regex) self.expected_regex = expected_regex + self.obj_name = None self.msg = None - def handle(self, name, callable_obj, args, kwargs): + def handle(self, name, args, kwargs): """ - If callable_obj is None, assertRaises/Warns is being used as a + If args is empty, assertRaises/Warns is being used as a context manager, so check for a 'msg' kwarg and return self. - If callable_obj is not None, call it passing args and kwargs. + If args is not empty, call a callable passing positional and keyword + arguments. """ - if callable_obj is None: + if not _is_subtype(self.expected, self._base_type): + raise TypeError('%s() arg 1 must be %s' % + (name, self._base_type_str)) + if args and args[0] is None: + warnings.warn("callable is None", + DeprecationWarning, 3) + args = () + if not args: self.msg = kwargs.pop('msg', None) + if kwargs: + warnings.warn('%r is an invalid keyword argument for ' + 'this function' % next(iter(kwargs)), + DeprecationWarning, 3) return self + + callable_obj = args[0] + args = args[1:] + try: + self.obj_name = callable_obj.__name__ + except AttributeError: + self.obj_name = str(callable_obj) with self: callable_obj(*args, **kwargs) @@ -181,6 +197,9 @@ class _AssertRaisesContext(_AssertRaisesBaseContext): """A context manager used to implement TestCase.assertRaises* methods.""" + _base_type = BaseException + _base_type_str = 'an exception type or tuple of exception types' + def __enter__(self): return self @@ -190,11 +209,13 @@ exc_name = self.expected.__name__ except AttributeError: exc_name = str(self.expected) - raise self.failureException( - "%s not raised" % (exc_name,)) - #else: - # if getattr(traceback, 'clear_frames', None): - # traceback.clear_frames(tb) + if self.obj_name: + self._raiseFailure("{0} not raised by {1}".format(exc_name, + self.obj_name)) + else: + self._raiseFailure("{0} not raised".format(exc_name)) + else: + traceback.clear_frames(tb) if not issubclass(exc_type, self.expected): # let unexpected exceptions pass through return False @@ -212,6 +233,9 @@ class _AssertWarnsContext(_AssertRaisesBaseContext): """A context manager used to implement TestCase.assertWarns* methods.""" + _base_type = Warning + _base_type_str = 'a warning type or tuple of warning types' + def __enter__(self): # The __warningregistry__'s need to be in a pristine state for tests # to work properly. @@ -697,15 +721,15 @@ return '%s : %s' % (safe_str(standardMsg), safe_str(msg)) - def assertRaises(self, excClass, callableObj=None, *args, **kwargs): - """Fail unless an exception of class excClass is raised - by callableObj when invoked with arguments args and keyword - arguments kwargs. If a different type of exception is + def assertRaises(self, expected_exception, *args, **kwargs): + """Fail unless an exception of class expected_exception is raised + by the callable when invoked with specified positional and + keyword arguments. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception. - If called with callableObj omitted or None, will return a + If called with the callable and arguments omitted, will return a context object used like this:: with self.assertRaises(SomeException): @@ -720,28 +744,18 @@ the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - if callableObj is None: - return _AssertRaisesContext(excClass, self) - try: - callableObj(*args, **kwargs) - except excClass: - return - - if hasattr(excClass,'__name__'): - excName = excClass.__name__ - else: - excName = str(excClass) - raise self.failureException("%s not raised" % excName) + context = _AssertRaisesContext(expected_exception, self) + return context.handle('assertRaises', args, kwargs) - def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs): + def assertWarns(self, expected_warning, *args, **kwargs): """Fail unless a warning of class warnClass is triggered - by callableObj when invoked with arguments args and keyword - arguments kwargs. If a different type of warning is + by the callable when invoked with specified positional and + keyword arguments. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception. - If called with callableObj omitted or None, will return a + If called with the callable and arguments omitted, will return a context object used like this:: with self.assertWarns(SomeWarning): @@ -749,7 +763,7 @@ The context manager keeps a reference to the first matching warning as the 'warning' attribute; similarly, the 'filename' - and 'lineno' attributes give you information about the line + and 'lineno' attributes give you information about the line of Python code from which the warning was triggered. This allows you to inspect the warning after the assertion:: @@ -758,19 +772,8 @@ the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self, callable_obj) - if callable_obj is None: - return context - context.__enter__() - try: - callable_obj(*args, **kwargs) - except: - if not context.__exit__(*sys.exc_info()): - raise - else: - return - else: - context.__exit__(None, None, None) + context = _AssertWarnsContext(expected_warning, self) + return context.handle('assertWarns', args, kwargs) def assertLogs(self, logger=None, level=None): """Fail unless a log message of level *level* or higher is emitted @@ -1261,23 +1264,21 @@ self.fail(self._formatMessage(msg, standardMsg)) def assertRaisesRegex(self, expected_exception, expected_regex, - callable_obj=None, *args, **kwargs): + *args, **kwargs): """Asserts that the message in a raised exception matches a regex. Args: expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - callable_obj: Function to be called. - args: Extra args. + args: Function to be called and extra positional args. kwargs: Extra kwargs. """ - context = _AssertRaisesContext(expected_exception, self, callable_obj, - expected_regex) - return context.handle('assertRaisesRegex', callable_obj, args, kwargs) + context = _AssertRaisesContext(expected_exception, self, expected_regex) + return context.handle('assertRaisesRegex', args, kwargs) def assertWarnsRegex(self, expected_warning, expected_regex, - callable_obj=None, *args, **kwargs): + *args, **kwargs): """Asserts that the message in a triggered warning matches a regex. Basic functioning is similar to assertWarns() with the addition that only warnings whose messages also match the regular expression @@ -1287,14 +1288,11 @@ expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - callable_obj: Function to be called. - args: Extra args. + args: Function to be called and extra positional args. kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, callable_obj, - expected_regex) - return context.handle('assertWarnsRegex', callable_obj, args, kwargs) - + context = _AssertWarnsContext(expected_warning, self, expected_regex) + return context.handle('assertWarnsRegex', args, kwargs) def assertRegex(self, text, expected_regex, msg=None): """Fail the test unless the text matches the regular expression.""" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/unittest2-1.0.1/unittest2/loader.py new/unittest2-1.1.0/unittest2/loader.py --- old/unittest2-1.0.1/unittest2/loader.py 2014-11-04 15:32:19.000000000 +0100 +++ new/unittest2-1.1.0/unittest2/loader.py 2015-06-29 12:04:21.000000000 +0200 @@ -31,29 +31,40 @@ return K -# what about .pyc or .pyo (etc) +# what about .pyc (etc) # we would need to avoid loading the same tests multiple times -# from '.py', '.pyc' *and* '.pyo' +# from '.py', *and* '.pyc' VALID_MODULE_NAME = re.compile(r'[_a-z]\w*\.py$', re.IGNORECASE) +class _FailedTest(case.TestCase): + _testMethodName = None + + def __init__(self, method_name, exception): + self._exception = exception + super(_FailedTest, self).__init__(method_name) + + def __getattr__(self, name): + if name != self._testMethodName: + return super(_FailedTest, self).__getattr__(name) + def testFailure(): + raise self._exception + return testFailure + + def _make_failed_import_test(name, suiteClass): message = 'Failed to import test module: %s\n%s' % ( name, traceback.format_exc()) - return _make_failed_test('ModuleImportFailure', name, ImportError(message), - suiteClass, message) + return _make_failed_test(name, ImportError(message), suiteClass, message) def _make_failed_load_tests(name, exception, suiteClass): message = 'Failed to call load_tests:\n%s' % (traceback.format_exc(),) return _make_failed_test( - 'LoadTestsFailure', name, exception, suiteClass, message) + name, exception, suiteClass, message) -def _make_failed_test(classname, methodname, exception, suiteClass, message): - def testFailure(self): - raise exception - attrs = {methodname: testFailure} - TestClass = type(classname, (case.TestCase,), attrs) - return suiteClass((TestClass(methodname),)), message +def _make_failed_test(methodname, exception, suiteClass, message): + test = _FailedTest(methodname, exception) + return suiteClass((test,)), message def _make_skipped_test(methodname, exception, suiteClass): @@ -188,7 +199,7 @@ else: # Otherwise, we signal that an AttributeError has occurred. error_case, error_message = _make_failed_test( - 'AttributeError', part, e, self.suiteClass, + part, e, self.suiteClass, 'Failed to access attribute:\n%s' % ( traceback.format_exc(),)) self.errors.append(error_message) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/unittest2-1.0.1/unittest2/test/_test_unittest2_with.py new/unittest2-1.1.0/unittest2/test/_test_unittest2_with.py --- old/unittest2-1.0.1/unittest2/test/_test_unittest2_with.py 2014-10-22 00:51:22.000000000 +0200 +++ new/unittest2-1.1.0/unittest2/test/_test_unittest2_with.py 2015-06-29 12:23:32.000000000 +0200 @@ -45,7 +45,7 @@ self.assertRaises(KeyError, lambda: None) except self.failureException: e = sys.exc_info()[1] - self.assertIn("KeyError not raised", e.args) + self.assertIn("KeyError not raised by <lambda>", e.args) else: self.fail("assertRaises() didn't fail") try: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/unittest2-1.0.1/unittest2/test/support.py new/unittest2-1.1.0/unittest2/test/support.py --- old/unittest2-1.0.1/unittest2/test/support.py 2014-10-29 11:38:26.000000000 +0100 +++ new/unittest2-1.1.0/unittest2/test/support.py 2015-06-29 12:24:31.000000000 +0200 @@ -135,8 +135,6 @@ try: if not hash(obj_1) == hash(obj_2): self.fail("%r and %r do not hash equal" % (obj_1, obj_2)) - except KeyboardInterrupt: - raise except Exception: e = sys.exc_info()[1] self.fail("Problem hashing %r and %r: %s" % (obj_1, obj_2, e)) @@ -146,8 +144,6 @@ if hash(obj_1) == hash(obj_2): self.fail("%s and %s hash equal, but shouldn't" % (obj_1, obj_2)) - except KeyboardInterrupt: - raise except Exception: e = sys.exc_info()[1] self.fail("Problem hashing %s and %s: %s" % (obj_1, obj_2, e)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/unittest2-1.0.1/unittest2/test/test_assertions.py new/unittest2-1.1.0/unittest2/test/test_assertions.py --- old/unittest2-1.0.1/unittest2/test/test_assertions.py 2014-10-31 00:48:15.000000000 +0100 +++ new/unittest2-1.1.0/unittest2/test/test_assertions.py 2015-06-30 08:19:24.000000000 +0200 @@ -75,6 +75,10 @@ getattr(sys, 'pypy_version_info', None), "pypy doesn't use refcounting." ) + @unittest.skipIf( + sys.version_info[:2] in ((3, 2), (3, 3)), + "python 3.2 and 3.3 always leak." + ) def test_assertRaises_frames_survival(self): # Issue #9815: assertRaises should avoid keeping local variables # in a traceback alive. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/unittest2-1.0.1/unittest2/test/test_case.py new/unittest2-1.1.0/unittest2/test/test_case.py --- old/unittest2-1.0.1/unittest2/test/test_case.py 2015-03-06 05:45:21.000000000 +0100 +++ new/unittest2-1.1.0/unittest2/test/test_case.py 2015-06-29 12:29:49.000000000 +0200 @@ -1052,6 +1052,71 @@ self.assertRaises(self.failureException, self.assertRegex, 'saaas', r'aaaa') + def testAssertRaisesCallable(self): + class ExceptionMock(Exception): + pass + def Stub(): + raise ExceptionMock('We expect') + self.assertRaises(ExceptionMock, Stub) + # A tuple of exception classes is accepted + self.assertRaises((ValueError, ExceptionMock), Stub) + # *args and **kwargs also work + self.assertRaises(ValueError, int, '19', base=8) + # Failure when no exception is raised + with self.assertRaises(self.failureException): + self.assertRaises(ExceptionMock, lambda: 0) + # Failure when the function is None + with self.assertWarns(DeprecationWarning): + self.assertRaises(ExceptionMock, None) + # Failure when another exception is raised + with self.assertRaises(ExceptionMock): + self.assertRaises(ValueError, Stub) + + def testAssertRaisesContext(self): + class ExceptionMock(Exception): + pass + def Stub(): + raise ExceptionMock('We expect') + with self.assertRaises(ExceptionMock): + Stub() + # A tuple of exception classes is accepted + with self.assertRaises((ValueError, ExceptionMock)) as cm: + Stub() + # The context manager exposes caught exception + self.assertIsInstance(cm.exception, ExceptionMock) + self.assertEqual(cm.exception.args[0], 'We expect') + # *args and **kwargs also work + with self.assertRaises(ValueError): + int('19', base=8) + # Failure when no exception is raised + with self.assertRaises(self.failureException): + with self.assertRaises(ExceptionMock): + pass + # Custom message + with self.assertRaisesRegex(self.failureException, 'foobar'): + with self.assertRaises(ExceptionMock, msg='foobar'): + pass + # Invalid keyword argument + with self.assertWarnsRegex(DeprecationWarning, 'foobar'): + with self.assertRaises(AssertionError): + with self.assertRaises(ExceptionMock, foobar=42): + pass + # Failure when another exception is raised + with self.assertRaises(ExceptionMock): + self.assertRaises(ValueError, Stub) + + def testAssertRaisesNoExceptionType(self): + with self.assertRaises(TypeError): + self.assertRaises() + with self.assertRaises(TypeError): + self.assertRaises(1) + with self.assertRaises(TypeError): + self.assertRaises(object) + with self.assertRaises(TypeError): + self.assertRaises((ValueError, 1)) + with self.assertRaises(TypeError): + self.assertRaises((ValueError, object)) + def testAssertRaisesRegex(self): class ExceptionMock(Exception): pass @@ -1062,20 +1127,27 @@ self.assertRaisesRegex(ExceptionMock, re.compile('expect$'), Stub) self.assertRaisesRegex(ExceptionMock, 'expect$', Stub) self.assertRaisesRegex(ExceptionMock, u('expect$'), Stub) + with self.assertWarns(DeprecationWarning): + self.assertRaisesRegex(ExceptionMock, 'expect$', None) def testAssertNotRaisesRegex(self): self.assertRaisesRegex( - self.failureException, '^Exception not raised$', + self.failureException, '^Exception not raised by <lambda>$', self.assertRaisesRegex, Exception, re.compile('x'), lambda: None) self.assertRaisesRegex( - self.failureException, '^Exception not raised$', + self.failureException, '^Exception not raised by <lambda>$', self.assertRaisesRegex, Exception, 'x', lambda: None) - self.assertRaisesRegex( - self.failureException, '^Exception not raised$', - self.assertRaisesRegex, Exception, u('x'), - lambda: None) + # Custom message + with self.assertRaisesRegex(self.failureException, 'foobar'): + with self.assertRaisesRegex(Exception, 'expect', msg='foobar'): + pass + # Invalid keyword argument + with self.assertWarnsRegex(DeprecationWarning, 'foobar'): + with self.assertRaises(AssertionError): + with self.assertRaisesRegex(Exception, 'expect', foobar=42): + pass def testAssertRaisesRegexInvalidRegex(self): # Issue 20145. @@ -1121,6 +1193,50 @@ self.assertRaisesRegex, Exception, re.compile('^Expected$'), Stub) + def testAssertRaisesRegexNoExceptionType(self): + with self.assertRaises(TypeError): + self.assertRaisesRegex() + with self.assertRaises(TypeError): + self.assertRaisesRegex(ValueError) + with self.assertRaises(TypeError): + self.assertRaisesRegex(1, 'expect') + with self.assertRaises(TypeError): + self.assertRaisesRegex(object, 'expect') + with self.assertRaises(TypeError): + self.assertRaisesRegex((ValueError, 1), 'expect') + with self.assertRaises(TypeError): + self.assertRaisesRegex((ValueError, object), 'expect') + + def testAssertWarnsNoExceptionType(self): + with self.assertRaises(TypeError): + self.assertWarns() + with self.assertRaises(TypeError): + self.assertWarns(1) + with self.assertRaises(TypeError): + self.assertWarns(object) + with self.assertRaises(TypeError): + self.assertWarns((UserWarning, 1)) + with self.assertRaises(TypeError): + self.assertWarns((UserWarning, object)) + with self.assertRaises(TypeError): + self.assertWarns((UserWarning, Exception)) + + def testAssertWarnsRegexNoExceptionType(self): + with self.assertRaises(TypeError): + self.assertWarnsRegex() + with self.assertRaises(TypeError): + self.assertWarnsRegex(UserWarning) + with self.assertRaises(TypeError): + self.assertWarnsRegex(1, 'expect') + with self.assertRaises(TypeError): + self.assertWarnsRegex(object, 'expect') + with self.assertRaises(TypeError): + self.assertWarnsRegex((UserWarning, 1), 'expect') + with self.assertRaises(TypeError): + self.assertWarnsRegex((UserWarning, object), 'expect') + with self.assertRaises(TypeError): + self.assertWarnsRegex((UserWarning, Exception), 'expect') + @contextlib.contextmanager def assertNoStderr(self): with captured_stderr() as buf: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/unittest2-1.0.1/unittest2/test/test_discovery.py new/unittest2-1.1.0/unittest2/test/test_discovery.py --- old/unittest2-1.0.1/unittest2/test/test_discovery.py 2014-11-04 15:11:54.000000000 +0100 +++ new/unittest2-1.1.0/unittest2/test/test_discovery.py 2015-06-29 06:17:45.000000000 +0200 @@ -3,6 +3,7 @@ import re import sys import types +import pickle try: import builtins except ImportError: @@ -491,6 +492,10 @@ test.my_package() self.assertEqual(import_calls, ['my_package']) + # Check picklability + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + pickle.loads(pickle.dumps(test, proto)) + def test_discover_with_module_that_raises_SkipTest_on_import(self): loader = unittest.TestLoader() @@ -527,6 +532,10 @@ self.assertEqual(result.testsRun, 1) self.assertEqual(import_calls, ['my_package']) + # Check picklability + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + pickle.loads(pickle.dumps(suite, proto)) + def test_command_line_handling_parseArgs(self): # Haha - take that uninstantiable class program = TestableTestProgram() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/unittest2-1.0.1/unittest2.egg-info/PKG-INFO new/unittest2-1.1.0/unittest2.egg-info/PKG-INFO --- old/unittest2-1.0.1/unittest2.egg-info/PKG-INFO 2015-03-12 03:56:02.000000000 +0100 +++ new/unittest2-1.1.0/unittest2.egg-info/PKG-INFO 2015-06-30 08:48:20.000000000 +0200 @@ -1,10 +1,10 @@ Metadata-Version: 1.1 Name: unittest2 -Version: 1.0.1 +Version: 1.1.0 Summary: The new features in unittest backported to Python 2.4+. Home-page: http://pypi.python.org/pypi/unittest2 -Author: Michael Foord -Author-email: michael@voidspace.org.uk +Author: Robert Collins +Author-email: rbtcollins@hp.com License: UNKNOWN Description: unittest2 is a backport of the new features added to the unittest testing framework in Python 2.7 and onwards. It is tested to run on Python 2.6, 2.7, @@ -175,6 +175,21 @@ CHANGELOG ========= + 2015-06-20 - 1.1.0 + ------------------ + + - Issue #15836: assertRaises(), assertRaisesRegex(), assertWarns() and + assertWarnsRegex() assertments now check the type of the first argument + to prevent possible user error. Based on patch by Daniel Wagner-Hall. + + - Issue #24134: assertRaises(), assertRaisesRegex(), assertWarns() and + assertWarnsRegex() checks now emits a deprecation warning when callable is + None or keyword arguments except msg is passed in the context manager mode. + + - Issue #22903: The fake test case created by unittest.loader when it fails + importing a test module is now picklable. + + 2015-03-12 - 1.0.1 ------------------