Hello community, here is the log from the commit of package python-six for openSUSE:Factory checked in at 2015-01-27 09:08:25 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-six (Old) and /work/SRC/openSUSE:Factory/.python-six.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-six" Changes: -------- --- /work/SRC/openSUSE:Factory/python-six/python-six.changes 2014-09-17 21:23:35.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.python-six.new/python-six.changes 2015-01-27 09:08:27.000000000 +0100 @@ -1,0 +2,18 @@ +Sat Jan 24 13:45:42 UTC 2015 - mailaen...@opensuse.org + +- update to version 1.9.0 + - Issue #106: Support the `flush` parameter to `six.print_`. + - Pull request #48 and issue #15: Add the `python_2_unicode_compatible` + decorator. + - Pull request #57 and issue #50: Add several compatibility methods for + unittest assertions that were renamed between Python 2 and 3. + - Issue #105 and pull request #58: Ensure `six.wraps` respects the + *updated* and *assigned* arguments. + - Issue #102: Add `raise_from` to abstract out Python 3's raise from + syntax. + - Issue #97: Optimize `six.iterbytes` on Python 2. + - Issue #98: Fix `six.moves` race condition in multi-threaded code. + - Pull request #51: Add `six.view(keys|values|itmes)`, which provide + dictionary views on Python 2.7+. + +------------------------------------------------------------------- Old: ---- six-1.8.0.tar.gz New: ---- six-1.9.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-six.spec ++++++ --- /var/tmp/diff_new_pack.UH4Snc/_old 2015-01-27 09:08:28.000000000 +0100 +++ /var/tmp/diff_new_pack.UH4Snc/_new 2015-01-27 09:08:28.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-six # -# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: python-six -Version: 1.8.0 +Version: 1.9.0 Release: 0 Url: http://pypi.python.org/pypi/six/ Summary: Python 2 and 3 compatibility utilities ++++++ six-1.8.0.tar.gz -> six-1.9.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/six-1.8.0/CHANGES new/six-1.9.0/CHANGES --- old/six-1.8.0/CHANGES 2014-09-11 23:42:45.000000000 +0200 +++ new/six-1.9.0/CHANGES 2015-01-02 17:34:00.000000000 +0100 @@ -3,38 +3,61 @@ This file lists the changes in each six version. +1.9.0 +----- + +- Issue #106: Support the `flush` parameter to `six.print_`. + +- Pull request #48 and issue #15: Add the `python_2_unicode_compatible` + decorator. + +- Pull request #57 and issue #50: Add several compatibility methods for unittest + assertions that were renamed between Python 2 and 3. + +- Issue #105 and pull request #58: Ensure `six.wraps` respects the *updated* and + *assigned* arguments. + +- Issue #102: Add `raise_from` to abstract out Python 3's raise from syntax. + +- Issue #97: Optimize `six.iterbytes` on Python 2. + +- Issue #98: Fix `six.moves` race condition in multi-threaded code. + +- Pull request #51: Add `six.view(keys|values|itmes)`, which provide dictionary + views on Python 2.7+. + 1.8.0 ----- -- Issue #90: Add six.moves.shlex_quote. +- Issue #90: Add `six.moves.shlex_quote`. -- Issue #59: Add six.moves.intern. +- Issue #59: Add `six.moves.intern`. -- Add six.urllib.parse.uses_(fragment|netloc|params|query|relative). +- Add `six.urllib.parse.uses_(fragment|netloc|params|query|relative)`. -- Issue #88: Fix add_metaclass when the class has __slots__ containing - "__weakref__" or "__dict__". +- Issue #88: Fix add_metaclass when the class has `__slots__` containing + `__weakref__` or `__dict__`. - Issue #89: Make six use absolute imports. -- Issue #85: Always accept *updated* and *assigned* arguments for wraps(). +- Issue #85: Always accept *updated* and *assigned* arguments for `wraps()`. -- Issue #86: In reraise(), instantiate the exception if the second argument is - None. +- Issue #86: In `reraise()`, instantiate the exception if the second argument is + `None`. -- Pull request #45: Add six.moves.email_mime_nonmultipart. +- Pull request #45: Add `six.moves.email_mime_nonmultipart`. -- Issue #81: Add six.urllib.request.splittag mapping. +- Issue #81: Add `six.urllib.request.splittag` mapping. -- Issue #80: Add six.urllib.request.splituser mapping. +- Issue #80: Add `six.urllib.request.splituser` mapping. 1.7.3 ----- - Issue #77: Fix import six on Python 3.4 with a custom loader. -- Issue #74: six.moves.xmlrpc_server should map to SimpleXMLRPCServer on Python - 2 as documented not xmlrpclib. +- Issue #74: `six.moves.xmlrpc_server` should map to `SimpleXMLRPCServer` on Python + 2 as documented not `xmlrpclib`. 1.7.2 ----- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/six-1.8.0/LICENSE new/six-1.9.0/LICENSE --- old/six-1.8.0/LICENSE 2014-01-04 23:36:04.000000000 +0100 +++ new/six-1.9.0/LICENSE 2015-01-02 17:31:35.000000000 +0100 @@ -1,4 +1,4 @@ -Copyright (c) 2010-2014 Benjamin Peterson +Copyright (c) 2010-2015 Benjamin Peterson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/six-1.8.0/PKG-INFO new/six-1.9.0/PKG-INFO --- old/six-1.8.0/PKG-INFO 2014-09-11 23:48:41.000000000 +0200 +++ new/six-1.9.0/PKG-INFO 2015-01-02 17:37:53.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: six -Version: 1.8.0 +Version: 1.9.0 Summary: Python 2 and 3 compatibility utilities Home-page: http://pypi.python.org/pypi/six/ Author: Benjamin Peterson @@ -17,8 +17,8 @@ Online documentation is at http://pythonhosted.org/six/. - Bugs can be reported to http://bitbucket.org/gutworth/six. The code can also be - found there. + Bugs can be reported to https://bitbucket.org/gutworth/six. The code can also + be found there. For questions about six or porting in general, email the python-porting mailing list: http://mail.python.org/mailman/listinfo/python-porting diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/six-1.8.0/README new/six-1.9.0/README --- old/six-1.8.0/README 2013-12-21 04:57:59.000000000 +0100 +++ new/six-1.9.0/README 2014-12-09 16:41:48.000000000 +0100 @@ -9,8 +9,8 @@ Online documentation is at http://pythonhosted.org/six/. -Bugs can be reported to http://bitbucket.org/gutworth/six. The code can also be -found there. +Bugs can be reported to https://bitbucket.org/gutworth/six. The code can also +be found there. For questions about six or porting in general, email the python-porting mailing list: http://mail.python.org/mailman/listinfo/python-porting diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/six-1.8.0/documentation/conf.py new/six-1.9.0/documentation/conf.py --- old/six-1.8.0/documentation/conf.py 2014-01-10 04:44:36.000000000 +0100 +++ new/six-1.9.0/documentation/conf.py 2015-01-02 17:31:23.000000000 +0100 @@ -33,7 +33,7 @@ # General information about the project. project = u"six" -copyright = u"2010-2014, Benjamin Peterson" +copyright = u"2010-2015, Benjamin Peterson" sys.path.append(os.path.abspath(os.path.join(".", ".."))) from six import __version__ as six_version @@ -213,5 +213,5 @@ # -- Intersphinx --------------------------------------------------------------- -intersphinx_mapping = {"py2" : ("http://docs.python.org/2/", None), - "py3" : ("http://docs.python.org/3/", None)} +intersphinx_mapping = {"py2" : ("https://docs.python.org/2/", None), + "py3" : ("https://docs.python.org/3/", None)} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/six-1.8.0/documentation/index.rst new/six-1.9.0/documentation/index.rst --- old/six-1.8.0/documentation/index.rst 2014-09-11 23:32:59.000000000 +0200 +++ new/six-1.9.0/documentation/index.rst 2015-01-02 17:11:56.000000000 +0100 @@ -18,7 +18,7 @@ The name, "six", comes from the fact that 2*3 equals 6. Why not addition? Multiplication is more powerful, and, anyway, "five" has already been snatched -away by the Zope Five project. +away by the (admittedly now moribund) Zope Five project. Indices and tables @@ -160,7 +160,7 @@ .. function:: next(it) -.. function:: advance_iterator(it) + advance_iterator(it) Get the next item of iterator *it*. :exc:`py3:StopIteration` is raised if the iterator is exhausted. This is a replacement for calling ``it.next()`` @@ -203,6 +203,27 @@ *kwargs* are passed through to the underlying method. +.. function:: viewkeys(dictionary) + + Return a view over *dictionary*\'s keys. This replaces + :meth:`py2:dict.viewkeys` on Python 2.7 and :meth:`py3:dict.keys` on + Python 3. + + +.. function:: viewvalues(dictionary) + + Return a view over *dictionary*\'s values. This replaces + :meth:`py2:dict.viewvalues` on Python 2.7 and :meth:`py3:dict.values` on + Python 3. + + +.. function:: viewitems(dictionary) + + Return a view over *dictionary*\'s items. This replaces + :meth:`py2:dict.viewitems` on Python 2.7 and :meth:`py3:dict.items` on + Python 3. + + .. function:: create_bound_method(func, obj) Return a method object wrapping *func* and bound to *obj*. On both Python 2 @@ -222,7 +243,7 @@ aliased to :class:`py3:object`.) -.. function:: wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS, updated=functools.WRAPPER_UPDATES) +.. decorator:: wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS, updated=functools.WRAPPER_UPDATES) This is exactly the :func:`py3:functools.wraps` decorator, but it sets the ``__wrapped__`` attribute on what it decorates as :func:`py3:functools.wraps` @@ -249,10 +270,11 @@ :func:`exec` with them should be avoided. -.. function:: print_(*args, *, file=sys.stdout, end="\\n", sep=" ") +.. function:: print_(*args, *, file=sys.stdout, end="\\n", sep=" ", flush=False) Print *args* into *file*. Each argument will be separated with *sep* and - *end* will be written to the file after the last argument is printed. + *end* will be written to the file after the last argument is printed. If + *flush* is true, ``file.flush()`` will be called after all data is written. .. note:: @@ -261,6 +283,13 @@ ok. :) +.. function:: raise_from(exc_value, exc_value_from) + + Raise an exception from a context. On Python 3, this is equivalent to + ``raise exc_value from exc_value_from``. On Python 2, which does not support + exception chaining, it is equivalent to ``raise exc_value``. + + .. function:: reraise(exc_type, exc_value, exc_traceback=None) Reraise an exception, possibly with a different traceback. In the simple @@ -292,7 +321,7 @@ decorator. -.. function:: add_metaclass(metaclass) +.. decorator:: add_metaclass(metaclass) Class decorator that replaces a normally-constructed class with a metaclass-constructed one. Example usage: :: @@ -409,6 +438,48 @@ :class:`py3:io.BytesIO`. +.. decorator:: python_2_unicode_compatible + + A class decorator that takes a class defining a ``__str__`` method. On + Python 3, the decorator does nothing. On Python 2, it aliases the + ``__str__`` method to ``__unicode__`` and creates a new ``__str__`` method + that returns the result of ``__unicode__()`` encoded with UTF-8. + + +unittest assertions +>>>>>>>>>>>>>>>>>>> + +Six contains compatibility shims for unittest assertions that have been renamed. +The parameters are the same as their aliases, but you must pass the test method +as the first argument. For example:: + + import six + import unittest + + class TestAssertCountEqual(unittest.TestCase): + def test(self): + six.assertCountEqual(self, (1, 2), [2, 1]) + +Note these functions are only available on Python 2.7 or later. + +.. function:: assertCountEqual() + + Alias for :meth:`~py3:unittest.TestCase.assertCountEqual` on Python 3 and + :meth:`~py2:unittest.TestCase.assertItemsEqual` on Python 2. + + +.. function:: assertRaisesRegex() + + Alias for :meth:`~py3:unittest.TestCase.assertRaisesRegex` on Python 3 and + :meth:`~py2:unittest.TestCase.assertRaisesRegexp` on Python 2. + + +.. function:: assertRegex() + + Alias for :meth:`~py3:unittest.TestCase.assertRegex` on Python 3 and + :meth:`~py2:unittest.TestCase.assertRegexpMatches` on Python 2. + + Renamed modules and attributes compatibility >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/six-1.8.0/setup.cfg new/six-1.9.0/setup.cfg --- old/six-1.8.0/setup.cfg 2014-09-11 23:48:41.000000000 +0200 +++ new/six-1.9.0/setup.cfg 2015-01-02 17:37:53.000000000 +0100 @@ -3,6 +3,6 @@ [egg_info] tag_build = -tag_date = 0 tag_svn_revision = 0 +tag_date = 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/six-1.8.0/six.egg-info/PKG-INFO new/six-1.9.0/six.egg-info/PKG-INFO --- old/six-1.8.0/six.egg-info/PKG-INFO 2014-09-11 23:48:40.000000000 +0200 +++ new/six-1.9.0/six.egg-info/PKG-INFO 2015-01-02 17:37:53.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: six -Version: 1.8.0 +Version: 1.9.0 Summary: Python 2 and 3 compatibility utilities Home-page: http://pypi.python.org/pypi/six/ Author: Benjamin Peterson @@ -17,8 +17,8 @@ Online documentation is at http://pythonhosted.org/six/. - Bugs can be reported to http://bitbucket.org/gutworth/six. The code can also be - found there. + Bugs can be reported to https://bitbucket.org/gutworth/six. The code can also + be found there. For questions about six or porting in general, email the python-porting mailing list: http://mail.python.org/mailman/listinfo/python-porting diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/six-1.8.0/six.py new/six-1.9.0/six.py --- old/six-1.8.0/six.py 2014-09-11 23:42:33.000000000 +0200 +++ new/six-1.9.0/six.py 2015-01-02 17:33:48.000000000 +0100 @@ -1,6 +1,6 @@ """Utilities for writing code that runs on Python 2 and 3""" -# Copyright (c) 2010-2014 Benjamin Peterson +# Copyright (c) 2010-2015 Benjamin Peterson # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,12 +23,13 @@ from __future__ import absolute_import import functools +import itertools import operator import sys import types __author__ = "Benjamin Peterson <benja...@python.org>" -__version__ = "1.8.0" +__version__ = "1.9.0" # Useful for very coarse version differentiation. @@ -88,8 +89,12 @@ def __get__(self, obj, tp): result = self._resolve() setattr(obj, self.name, result) # Invokes __set__. - # This is a bit ugly, but it avoids running this again. - delattr(obj.__class__, self.name) + try: + # This is a bit ugly, but it avoids running this again by + # removing this descriptor. + delattr(obj.__class__, self.name) + except AttributeError: + pass return result @@ -554,6 +559,12 @@ def iterlists(d, **kw): return iter(d.lists(**kw)) + + viewkeys = operator.methodcaller("keys") + + viewvalues = operator.methodcaller("values") + + viewitems = operator.methodcaller("items") else: def iterkeys(d, **kw): return iter(d.iterkeys(**kw)) @@ -567,6 +578,12 @@ def iterlists(d, **kw): return iter(d.iterlists(**kw)) + viewkeys = operator.methodcaller("viewkeys") + + viewvalues = operator.methodcaller("viewvalues") + + viewitems = operator.methodcaller("viewitems") + _add_doc(iterkeys, "Return an iterator over the keys of a dictionary.") _add_doc(itervalues, "Return an iterator over the values of a dictionary.") _add_doc(iteritems, @@ -593,6 +610,9 @@ import io StringIO = io.StringIO BytesIO = io.BytesIO + _assertCountEqual = "assertCountEqual" + _assertRaisesRegex = "assertRaisesRegex" + _assertRegex = "assertRegex" else: def b(s): return s @@ -605,14 +625,28 @@ return ord(bs[0]) def indexbytes(buf, i): return ord(buf[i]) - def iterbytes(buf): - return (ord(byte) for byte in buf) + iterbytes = functools.partial(itertools.imap, ord) import StringIO StringIO = BytesIO = StringIO.StringIO + _assertCountEqual = "assertItemsEqual" + _assertRaisesRegex = "assertRaisesRegexp" + _assertRegex = "assertRegexpMatches" _add_doc(b, """Byte literal""") _add_doc(u, """Text literal""") +def assertCountEqual(self, *args, **kwargs): + return getattr(self, _assertCountEqual)(*args, **kwargs) + + +def assertRaisesRegex(self, *args, **kwargs): + return getattr(self, _assertRaisesRegex)(*args, **kwargs) + + +def assertRegex(self, *args, **kwargs): + return getattr(self, _assertRegex)(*args, **kwargs) + + if PY3: exec_ = getattr(moves.builtins, "exec") @@ -643,6 +677,21 @@ """) +if sys.version_info[:2] == (3, 2): + exec_("""def raise_from(value, from_value): + if from_value is None: + raise value + raise value from from_value +""") +elif sys.version_info[:2] > (3, 2): + exec_("""def raise_from(value, from_value): + raise value from from_value +""") +else: + def raise_from(value, from_value): + raise value + + print_ = getattr(moves.builtins, "print", None) if print_ is None: def print_(*args, **kwargs): @@ -697,6 +746,14 @@ write(sep) write(arg) write(end) +if sys.version_info[:2] < (3, 3): + _print = print_ + def print_(*args, **kwargs): + fp = kwargs.get("file", sys.stdout) + flush = kwargs.pop("flush", False) + _print(*args, **kwargs) + if flush and fp is not None: + fp.flush() _add_doc(reraise, """Reraise an exception.""") @@ -704,7 +761,7 @@ def wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS, updated=functools.WRAPPER_UPDATES): def wrapper(f): - f = functools.wraps(wrapped)(f) + f = functools.wraps(wrapped, assigned, updated)(f) f.__wrapped__ = wrapped return f return wrapper @@ -737,6 +794,25 @@ return metaclass(cls.__name__, cls.__bases__, orig_vars) return wrapper + +def python_2_unicode_compatible(klass): + """ + A decorator that defines __unicode__ and __str__ methods under Python 2. + Under Python 3 it does nothing. + + To support Python 2 and 3 with a single code base, define a __str__ method + returning text and apply this decorator to the class. + """ + if PY2: + if '__str__' not in klass.__dict__: + raise ValueError("@python_2_unicode_compatible cannot be applied " + "to %s because it doesn't define __str__()." % + klass.__name__) + klass.__unicode__ = klass.__str__ + klass.__str__ = lambda self: self.__unicode__().encode('utf-8') + return klass + + # Complete the moves implementation. # This code is at the end of this module to speed up module loading. # Turn this module into a package. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/six-1.8.0/test_six.py new/six-1.9.0/test_six.py --- old/six-1.8.0/test_six.py 2014-08-18 06:25:25.000000000 +0200 +++ new/six-1.9.0/test_six.py 2015-01-02 17:07:03.000000000 +0100 @@ -1,6 +1,7 @@ import operator import sys import types +import unittest import py @@ -389,6 +390,24 @@ monkeypatch.undo() +@py.test.mark.skipif(sys.version_info[:2] < (2, 7), + reason="view methods on dictionaries only available on 2.7+") +def test_dictionary_views(): + def stock_method_name(viewwhat): + """Given a method suffix like "keys" or "values", return the name + of the dict method that delivers those on the version of Python + we're running in.""" + if six.PY3: + return viewwhat + return 'view' + viewwhat + + d = dict(zip(range(10), (range(11, 20)))) + for name in "keys", "values", "items": + meth = getattr(six, "view" + name) + view = meth(d) + assert set(view) == set(getattr(d, name)()) + + def test_advance_iterator(): assert six.next is six.advance_iterator l = [1, 2] @@ -570,6 +589,27 @@ assert tb is get_next(tb2) +def test_raise_from(): + try: + try: + raise Exception("blah") + except Exception: + ctx = sys.exc_info()[1] + f = Exception("foo") + six.raise_from(f, None) + except Exception: + tp, val, tb = sys.exc_info() + if sys.version_info[:2] > (3, 0): + # We should have done a raise f from None equivalent. + assert val.__cause__ is None + assert val.__context__ is ctx + if sys.version_info[:2] >= (3, 3): + # And that should suppress the context on the exception. + assert val.__suppress_context__ + # For all versions the outer exception should have raised successfully. + assert str(val) == "foo" + + def test_print_(): save = sys.stdout out = sys.stdout = six.moves.StringIO() @@ -596,6 +636,17 @@ out = six.StringIO() six.print_(None, file=out) assert out.getvalue() == "None\n" + class FlushableStringIO(six.StringIO): + def __init__(self): + six.StringIO.__init__(self) + self.flushed = False + def flush(self): + self.flushed = True + out = FlushableStringIO() + six.print_("Hello", file=out) + assert not out.flushed + six.print_("Hello", file=out, flush=True) + assert out.flushed @py.test.mark.skipif("sys.version_info[:2] >= (2, 6)") @@ -662,6 +713,18 @@ assert k is original_k assert not hasattr(k, '__wrapped__') + def f(g, assign, update): + def w(): + return 42 + w.glue = {"foo" : "bar"} + return six.wraps(g, assign, update)(w) + k.glue = {"melon" : "egg"} + k.turnip = 43 + k = f(k, ["turnip"], ["glue"]) + assert k.__name__ == "w" + assert k.turnip == 43 + assert k.glue == {"melon" : "egg", "foo" : "bar"} + def test_add_metaclass(): class Meta(type): @@ -734,3 +797,62 @@ __slots__ = "__weakref__", MySlotsWeakref = six.add_metaclass(Meta)(MySlotsWeakref) assert type(MySlotsWeakref) is Meta + + +@py.test.mark.skipif("sys.version_info[:2] < (2, 7)") +def test_assertCountEqual(): + class TestAssertCountEqual(unittest.TestCase): + def test(self): + with self.assertRaises(AssertionError): + six.assertCountEqual(self, (1, 2), [3, 4, 5]) + + six.assertCountEqual(self, (1, 2), [2, 1]) + + TestAssertCountEqual('test').test() + + +@py.test.mark.skipif("sys.version_info[:2] < (2, 7)") +def test_assertRegex(): + class TestAssertRegex(unittest.TestCase): + def test(self): + with self.assertRaises(AssertionError): + six.assertRegex(self, 'test', r'^a') + + six.assertRegex(self, 'test', r'^t') + + TestAssertRegex('test').test() + + +@py.test.mark.skipif("sys.version_info[:2] < (2, 7)") +def test_assertRaisesRegex(): + class TestAssertRaisesRegex(unittest.TestCase): + def test(self): + with six.assertRaisesRegex(self, AssertionError, '^Foo'): + raise AssertionError('Foo') + + with self.assertRaises(AssertionError): + with six.assertRaisesRegex(self, AssertionError, r'^Foo'): + raise AssertionError('Bar') + + TestAssertRaisesRegex('test').test() + + +def test_python_2_unicode_compatible(): + @six.python_2_unicode_compatible + class MyTest(object): + def __str__(self): + return six.u('hello') + + def __bytes__(self): + return six.b('hello') + + my_test = MyTest() + + if six.PY2: + assert str(my_test) == six.b("hello") + assert unicode(my_test) == six.u("hello") + elif six.PY3: + assert bytes(my_test) == six.b("hello") + assert str(my_test) == six.u("hello") + + assert getattr(six.moves.builtins, 'bytes', str)(my_test) == six.b("hello") -- To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org For additional commands, e-mail: opensuse-commit+h...@opensuse.org