← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/python-oops-wsgi/py3 into lp:python-oops-wsgi

 

Colin Watson has proposed merging lp:~cjwatson/python-oops-wsgi/py3 into lp:python-oops-wsgi.

Commit message:
Add Python 3 support.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/python-oops-wsgi/py3/+merge/341275

Requires the currently-unreleased tip of python-oops in order to work on Python 3, so we probably ought to release that first.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/python-oops-wsgi/py3 into lp:python-oops-wsgi.
=== modified file '.bzrignore'
--- .bzrignore	2011-11-13 21:54:04 +0000
+++ .bzrignore	2018-03-10 20:59:57 +0000
@@ -1,3 +1,4 @@
+__pycache__
 ./eggs/*
 ./.installed.cfg
 ./develop-eggs

=== modified file 'NEWS'
--- NEWS	2016-10-31 11:02:13 +0000
+++ NEWS	2018-03-10 20:59:57 +0000
@@ -3,6 +3,12 @@
 
 Changes and improvements to oops-wsgi, grouped by release.
 
+NEXT
+----
+
+* Fix test compatibility with testtools >= 0.9.17. (Colin Watson)
+* Add Python 3 support. (Colin Watson)
+
 0.0.12
 ------
 

=== modified file 'README'
--- README	2014-07-24 17:35:45 +0000
+++ README	2018-03-10 20:59:57 +0000
@@ -23,7 +23,7 @@
 Dependencies
 ============
 
-* Python 2.6+
+* Python 2.6+ or 3.3+
 
 * oops (http://pypi.python.org/pypi/oops)
 

=== modified file 'oops_wsgi/__init__.py'
--- oops_wsgi/__init__.py	2012-02-01 04:35:31 +0000
+++ oops_wsgi/__init__.py	2018-03-10 20:59:57 +0000
@@ -98,6 +98,8 @@
 """
 
 
+from __future__ import absolute_import, print_function
+
 # same format as sys.version_info: "A tuple containing the five components of
 # the version number: major, minor, micro, releaselevel, and serial. All
 # values except releaselevel are integers; the release level is 'alpha',

=== modified file 'oops_wsgi/django.py'
--- oops_wsgi/django.py	2011-12-12 05:39:47 +0000
+++ oops_wsgi/django.py	2018-03-10 20:59:57 +0000
@@ -23,7 +23,7 @@
 fixed in your Django.
 """
 
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
 
 from django.core.handlers import wsgi
 

=== modified file 'oops_wsgi/hooks.py'
--- oops_wsgi/hooks.py	2016-10-14 10:39:16 +0000
+++ oops_wsgi/hooks.py	2018-03-10 20:59:57 +0000
@@ -15,6 +15,8 @@
 
 """oops creation and filtering hooks for working with WSGI."""
 
+from __future__ import absolute_import, print_function
+
 import re
 
 __all__ = [

=== modified file 'oops_wsgi/middleware.py'
--- oops_wsgi/middleware.py	2014-07-24 17:53:23 +0000
+++ oops_wsgi/middleware.py	2018-03-10 20:59:57 +0000
@@ -15,12 +15,15 @@
 
 """WSGI middleware to integrate with an oops.Config."""
 
+from __future__ import absolute_import, print_function
+
 __metaclass__ = type
 
 import socket
 import sys
 import time
-from urllib import quote
+
+from six.moves.urllib_parse import quote
 
 __all__ = [
     'default_map_environ',

=== modified file 'oops_wsgi/tests/__init__.py'
--- oops_wsgi/tests/__init__.py	2011-11-13 21:57:57 +0000
+++ oops_wsgi/tests/__init__.py	2018-03-10 20:59:57 +0000
@@ -15,6 +15,8 @@
 
 """Tests for oops_wsgi."""
 
+from __future__ import absolute_import, print_function
+
 from unittest import TestLoader
 
 

=== modified file 'oops_wsgi/tests/test_hooks.py'
--- oops_wsgi/tests/test_hooks.py	2016-10-14 10:39:16 +0000
+++ oops_wsgi/tests/test_hooks.py	2018-03-10 20:59:57 +0000
@@ -15,7 +15,9 @@
 
 """Tests for the various hooks included in oops-wsgi."""
 
-from StringIO import StringIO
+from __future__ import absolute_import, print_function
+
+from io import BytesIO
 
 from oops import Config
 from testtools import TestCase
@@ -91,7 +93,7 @@
             'HTTP_COOKIE': 'zaphod',
             'wsgi.version': (1, 0),
             'wsgi.url_scheme': 'https',
-            'wsgi.input': StringIO(),
+            'wsgi.input': BytesIO(),
             }
         context = dict(wsgi_environ=environ)
         report = {}

=== modified file 'oops_wsgi/tests/test_middleware.py'
--- oops_wsgi/tests/test_middleware.py	2013-05-22 15:59:31 +0000
+++ oops_wsgi/tests/test_middleware.py	2018-03-10 20:59:57 +0000
@@ -15,6 +15,8 @@
 
 """Tests for the middleware."""
 
+from __future__ import absolute_import, print_function
+
 import errno
 from doctest import ELLIPSIS
 import gc
@@ -23,10 +25,7 @@
 from textwrap import dedent
 import time
 
-from oops import (
-    Config,
-    createhooks,
-    )
+from oops import Config
 from testtools import TestCase
 from testtools.matchers import (
     DocTestMatches,
@@ -34,7 +33,6 @@
     MatchesException,
     MatchesListwise,
     Mismatch,
-    MismatchesAll,
     raises,
     )
 
@@ -42,6 +40,19 @@
 from oops_wsgi.middleware import generator_tracker
 
 
+class MismatchesOOPS(Mismatch):
+
+    def __init__(self, mismatches):
+        self.mismatches = mismatches
+
+    def describe(self):
+        descriptions = ["Differences: ["]
+        for mismatch in self.mismatches:
+            descriptions.append(mismatch.describe())
+        descriptions.append("]")
+        return '\n'.join(descriptions)
+
+
 class MatchesOOPS:
     """Matches an OOPS checking some keys and ignoring the rest."""
 
@@ -74,7 +85,7 @@
             if mismatch is not None:
                 mismatches.append(mismatch)
         if mismatches:
-            return MismatchesAll(mismatches)
+            return MismatchesOOPS(mismatches)
 
     def __str__(self):
         return "MatchesOOPS(%s)" % self.checkkeys
@@ -140,7 +151,7 @@
             iterator = iter(app(environ, start_response))
             # get one item from it, which is enough to ensure we've activated
             # all the frames.
-            step = iterator.next()
+            step = next(iterator)
             # the client pipe is closed or something - we discard the iterator
             del iterator
             gc.collect()
@@ -627,7 +638,7 @@
         tracker = generator_tracker(
             self.on_first_bytes, self.on_finish, self.on_exception_fail,
             failing_iter())
-        self.assertThat(lambda:tracker.next(), raises(ValueError('fail')))
+        self.assertThat(lambda: next(tracker), raises(ValueError('fail')))
         self.assertEqual(['on exception foo'], self.calls)
 
     def test_closes_iterator(self):

=== modified file 'setup.py'
--- setup.py	2016-10-31 11:02:13 +0000
+++ setup.py	2018-03-10 20:59:57 +0000
@@ -19,8 +19,8 @@
 from distutils.core import setup
 import os.path
 
-description = file(
-        os.path.join(os.path.dirname(__file__), 'README'), 'rb').read()
+with open(os.path.join(os.path.dirname(__file__), 'README')) as f:
+    description = f.read()
 
 setup(name="oops_wsgi",
       version="0.0.12",
@@ -38,9 +38,12 @@
           'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)',
           'Operating System :: OS Independent',
           'Programming Language :: Python',
+          'Programming Language :: Python :: 2',
+          'Programming Language :: Python :: 3',
           ],
       install_requires = [
           'oops',
+          'six',
           ],
       extras_require = dict(
           test=[

=== modified file 'versions.cfg'
--- versions.cfg	2014-07-24 17:35:45 +0000
+++ versions.cfg	2018-03-10 20:59:57 +0000
@@ -7,6 +7,7 @@
 oops = 0.0.6
 pytz = 2010o
 setuptools = 0.6c11
+six = 1.11.0
 testtools = 0.9.11
 zc.recipe.egg = 1.3.2
 z3c.recipe.filetemplate = 2.1.0


Follow ups