← Back to team overview

testtools-dev team mailing list archive

[Merge] lp:~jseutter/testtools/py3_again into lp:testtools

 

Jerry Seutter has proposed merging lp:~jseutter/testtools/py3_again into lp:testtools.

Requested reviews:
  Barry Warsaw (barry)
  testtools committers (testtools-committers)

For more details, see:
https://code.launchpad.net/~jseutter/testtools/py3_again/+merge/105569

This is a new MP based off https://code.launchpad.net/~jseutter/testtools/py3/+merge/105505 that does not have files needlessly removed and added again.

This change adds support for building and installing using python 3. Previously this package could be used in both python 2 and python 3, but a "python setup.py install" using python 3 would fail when trying to compile _compat2x.py.

get_revno() will now silently fail if bzrlib is not present, as bzrlib is not yet available in python 3.


-- 
https://code.launchpad.net/~jseutter/testtools/py3_again/+merge/105569
Your team testtools developers is subscribed to branch lp:testtools.
=== modified file 'setup.py'
--- setup.py	2011-11-25 18:24:10 +0000
+++ setup.py	2012-05-12 22:44:17 +0000
@@ -9,8 +9,11 @@
 
 
 def get_revno():
-    import bzrlib.errors
-    import bzrlib.workingtree
+    try:
+        import bzrlib.errors
+        import bzrlib.workingtree
+    except ImportError:
+        return None
     try:
         t = bzrlib.workingtree.WorkingTree.open_containing(__file__)[0]
     except (bzrlib.errors.NotBranchError, bzrlib.errors.NoWorkingTree):

=== modified file 'testtools/_compat2x.py'
--- testtools/_compat2x.py	2011-07-26 23:08:51 +0000
+++ testtools/_compat2x.py	2012-05-12 22:44:17 +0000
@@ -13,5 +13,5 @@
 
 def reraise(exc_class, exc_obj, exc_tb, _marker=object()):
     """Re-raise an exception received from sys.exc_info() or similar."""
-    raise exc_class, exc_obj, exc_tb
+    raise (exc_class, exc_obj, exc_tb)
 

=== modified file 'testtools/compat.py'
--- testtools/compat.py	2011-12-05 15:21:33 +0000
+++ testtools/compat.py	2012-05-12 22:44:17 +0000
@@ -32,10 +32,10 @@
 BytesIO = try_imports(['StringIO.StringIO', 'io.BytesIO'])
 StringIO = try_imports(['StringIO.StringIO', 'io.StringIO'])
 
-try:
+if sys.version_info < (3, 0):
     from testtools import _compat2x as _compat
     _compat
-except SyntaxError:
+else:
     from testtools import _compat3x as _compat
 
 reraise = _compat.reraise


Follow ups