diff options
author | Cyril Roelandt <cyril.roelandt@enovance.com> | 2014-03-18 12:47:02 +0100 |
---|---|---|
committer | Cyril Roelandt <cyril.roelandt@enovance.com> | 2014-03-18 12:47:02 +0100 |
commit | 4262b41da195cb959abf4a5a06ce34a6dec2c4a3 (patch) | |
tree | cb6a9ef83ac83e6e6e0a90dd48ad9672b4e32a9d /paste/fixture.py | |
parent | 3f98341a08e2899fdf6914776198bd0878e4f5c2 (diff) | |
download | paste-4262b41da195cb959abf4a5a06ce34a6dec2c4a3.tar.gz |
Python 3: Use six types for strings
* Replace (str, unicode) with (six.binary_type, six.text_type)
* Replace basestring with (six.binary_type, six.text_type)
Diffstat (limited to 'paste/fixture.py')
-rw-r--r-- | paste/fixture.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/paste/fixture.py b/paste/fixture.py index 7a684e5..1b97c35 100644 --- a/paste/fixture.py +++ b/paste/fixture.py @@ -21,6 +21,7 @@ import shutil import smtplib import shlex import re +import six import subprocess from six.moves import cStringIO as StringIO from six.moves.urllib.parse import urlencode @@ -128,7 +129,7 @@ class TestApp(object): ``post_request_hook`` is a function, similar to ``pre_request_hook``, to be called after requests are made. """ - if isinstance(app, (str, unicode)): + if isinstance(app, (six.binary_type, six.text_type)): from paste.deploy import loadapp # @@: Should pick up relative_to from calling module's # __file__ @@ -192,7 +193,7 @@ class TestApp(object): # Hide from py.test: __tracebackhide__ = True if params: - if not isinstance(params, (str, unicode)): + if not isinstance(params, (six.binary_type, six.text_type)): params = urlencode(params, doseq=True) if '?' in url: url += '&' @@ -794,9 +795,9 @@ class TestResponse(object): of the response. Whitespace is normalized when searching for a string. """ - if not isinstance(s, (str, unicode)): + if not isinstance(s, (six.binary_type, six.text_type)): s = str(s) - if isinstance(s, unicode): + if isinstance(s, six.text_type): ## FIXME: we don't know that this response uses utf8: s = s.encode('utf8') return (self.body.find(s) != -1 @@ -814,7 +815,7 @@ class TestResponse(object): if 'no' in kw: no = kw['no'] del kw['no'] - if isinstance(no, basestring): + if isinstance(no, (six.binary_type, six.text_type)): no = [no] else: no = [] @@ -1687,7 +1688,7 @@ def _space_prefix(pref, full, sep=None, indent=None, include_sep=True): def _make_pattern(pat): if pat is None: return None - if isinstance(pat, (str, unicode)): + if isinstance(pat, (six.binary_type, six.text_type)): pat = re.compile(pat) if hasattr(pat, 'search'): return pat.search @@ -1713,7 +1714,7 @@ def setup_module(module=None): if module is None: # The module we were called from must be the module... module = sys._getframe().f_back.f_globals['__name__'] - if isinstance(module, (str, unicode)): + if isinstance(module, (six.binary_type, six.text_type)): module = sys.modules[module] if hasattr(module, 'reset_state'): module.reset_state() |