', 'single', 0xff)
# Raises TypeError in Python < v3.5, ValueError in v3.5:
- # self.assertRaises(TypeError, compile, chr(0), 'f', 'exec')
+ self.assertRaises((TypeError, ValueError), compile, chr(0), 'f', 'exec')
self.assertRaises(TypeError, compile, 'pass', '?', 'exec',
mode='eval', source='0', filename='tmp')
compile('print("\xe5")\n', '', 'exec')
- self.assertRaises(TypeError, compile, chr(0), 'f', 'exec')
self.assertRaises(ValueError, compile, str('a = 1'), 'f', 'bad')
# test the optimize argument
@@ -1100,6 +1098,14 @@ def test_max(self):
self.assertEqual(max(data, key=f),
sorted(reversed(data), key=f)[-1])
+ self.assertEqual(max([], default=5), 5)
+ with self.assertRaises(TypeError):
+ max(None, default=5)
+ with self.assertRaises(TypeError):
+ max(1, 2, default=0)
+ self.assertEqual(max([], default=0), 0)
+ self.assertIs(max([], default=None), None)
+
def test_min(self):
self.assertEqual(min('123123'), '1')
self.assertEqual(min(1, 2, 3), 1)
@@ -1117,6 +1123,7 @@ class BadSeq:
def __getitem__(self, index):
raise ValueError
self.assertRaises(ValueError, min, BadSeq())
+ self.assertEqual(max(x for x in [5, 4, 3]), 5)
for stmt in (
"min(key=int)", # no args
@@ -1141,6 +1148,16 @@ def __getitem__(self, index):
f = keys.__getitem__
self.assertEqual(min(data, key=f),
sorted(data, key=f)[0])
+ self.assertEqual(min([], default=5), 5)
+ self.assertEqual(min([], default=0), 0)
+ self.assertIs(min([], default=None), None)
+ with self.assertRaises(TypeError):
+ max(None, default=5)
+ with self.assertRaises(TypeError):
+ max(1, 2, default=0)
+
+ # Test iterables that can only be looped once #510
+ self.assertEqual(min(x for x in [5]), 5)
def test_next(self):
it = iter(range(2))
@@ -1287,7 +1304,7 @@ def test_pow(self):
self.assertAlmostEqual(pow(-1, 1/3), 0.5 + 0.8660254037844386j)
# Raises TypeError in Python < v3.5, ValueError in v3.5:
- # self.assertRaises(TypeError, pow, -1, -2, 3)
+ self.assertRaises((TypeError, ValueError), pow, -1, -2, 3)
self.assertRaises(ValueError, pow, 1, 2, 0)
self.assertRaises(TypeError, pow)
diff --git a/tests/test_future/test_bytes.py b/tests/test_future/test_bytes.py
index f30e7406..b9b157d8 100644
--- a/tests/test_future/test_bytes.py
+++ b/tests/test_future/test_bytes.py
@@ -29,6 +29,20 @@ def test_bytes_encoding_arg(self):
b = bytes(u, encoding='utf-8')
self.assertEqual(b, u.encode('utf-8'))
+ nu = str(u)
+ b = bytes(nu, encoding='utf-8')
+ self.assertEqual(b, u.encode('utf-8'))
+
+ def test_bytes_encoding_arg_issue_193(self):
+ """
+ This used to be True: bytes(str(u'abc'), 'utf8') == b"b'abc'"
+ """
+ u = u'abc'
+ b = bytes(str(u), 'utf8')
+ self.assertNotEqual(b, b"b'abc'")
+ self.assertEqual(b, b'abc')
+ self.assertEqual(b, bytes(b'abc'))
+
def test_bytes_encoding_arg_non_kwarg(self):
"""
As above, but with a positional argument
@@ -37,6 +51,10 @@ def test_bytes_encoding_arg_non_kwarg(self):
b = bytes(u, 'utf-8')
self.assertEqual(b, u.encode('utf-8'))
+ nu = str(u)
+ b = bytes(nu, 'utf-8')
+ self.assertEqual(b, u.encode('utf-8'))
+
def test_bytes_string_no_encoding(self):
with self.assertRaises(TypeError):
bytes(u'ABC')
@@ -142,7 +160,7 @@ def test_repr(self):
def test_str(self):
b = bytes(b'ABCD')
- self.assertTrue(str(b), "b'ABCD'")
+ self.assertEqual(str(b), "b'ABCD'")
def test_bytes_setitem(self):
b = b'ABCD'
@@ -290,7 +308,7 @@ def test_endswith(self):
exc = str(cm.exception)
# self.assertIn('bytes', exc)
# self.assertIn('tuple', exc)
-
+
def test_decode(self):
b = bytes(b'abcd')
s = b.decode('utf-8')
@@ -357,7 +375,7 @@ def test_hash(self):
d[s] = s
self.assertEqual(len(d), 2)
self.assertEqual(set(d.keys()), set([s, b]))
-
+
@unittest.expectedFailure
def test_hash_with_native_types(self):
# Warning: initializing the dict with native Py2 types throws the
@@ -478,7 +496,7 @@ def test_bytes_within_range(self):
ValueError
...
ValueError: bytes must be in range(0, 256)
-
+
Ensure our bytes() constructor has the same behaviour
"""
b1 = bytes([254, 255])
@@ -534,117 +552,164 @@ def test_maketrans(self):
self.assertRaises(ValueError, bytes.maketrans, b'abc', b'xyzq')
self.assertRaises(TypeError, bytes.maketrans, 'abc', 'def')
- @unittest.expectedFailure
+ @unittest.skipUnless(utils.PY2, 'test requires Python 2')
+ def test_mod_custom_dict(self):
+ import UserDict
+
+ class MyDict(UserDict.UserDict):
+ pass
+
+ d = MyDict()
+ d['foo'] = bytes(b'bar')
+ self.assertFalse(isinstance(d, dict))
+ self.assertTrue(isinstance(d, UserDict.UserDict))
+
+ self.assertEqual(bytes(b'%(foo)s') % d, b'bar')
+
+ @unittest.skipUnless(utils.PY35_PLUS or utils.PY2,
+ 'test requires Python 2 or 3.5+')
+ def test_mod_more(self):
+ self.assertEqual(b'%s' % b'aaa', b'aaa')
+ self.assertEqual(bytes(b'%s') % b'aaa', b'aaa')
+ self.assertEqual(bytes(b'%s') % bytes(b'aaa'), b'aaa')
+
+ self.assertEqual(b'%s' % (b'aaa',), b'aaa')
+ self.assertEqual(bytes(b'%s') % (b'aaa',), b'aaa')
+ self.assertEqual(bytes(b'%s') % (bytes(b'aaa'),), b'aaa')
+
+ self.assertEqual(bytes(b'%(x)s') % {b'x': b'aaa'}, b'aaa')
+ self.assertEqual(bytes(b'%(x)s') % {b'x': bytes(b'aaa')}, b'aaa')
+
+ @unittest.skipUnless(utils.PY35_PLUS or utils.PY2,
+ 'test requires Python 2 or 3.5+')
def test_mod(self):
"""
From Py3.5 test suite (post-PEP 461).
The bytes mod code is in _PyBytes_Format() in bytesobject.c in Py3.5.
"""
- b = b'hello, %b!'
- orig = b
- b = b % b'world'
- self.assertEqual(b, b'hello, world!')
- self.assertEqual(orig, b'hello, %b!')
- self.assertFalse(b is orig)
- b = b'%s / 100 = %d%%'
+
+ # XXX Add support for %b!
+ #
+ # b = bytes(b'hello, %b!')
+ # orig = b
+ # b = b % b'world'
+ # self.assertEqual(b, b'hello, world!')
+ # self.assertEqual(orig, b'hello, %b!')
+ # self.assertFalse(b is orig)
+
+ b = bytes(b'%s / 100 = %d%%')
a = b % (b'seventy-nine', 79)
self.assertEqual(a, b'seventy-nine / 100 = 79%')
- @unittest.expectedFailure
+ b = bytes(b'%s / 100 = %d%%')
+ a = b % (bytes(b'seventy-nine'), 79)
+ self.assertEqual(a, b'seventy-nine / 100 = 79%')
+
+ @unittest.skipUnless(utils.PY35_PLUS or utils.PY2,
+ 'test requires Python 2 or 3.5+')
def test_imod(self):
"""
From Py3.5 test suite (post-PEP 461)
"""
# if (3, 0) <= sys.version_info[:2] < (3, 5):
# raise unittest.SkipTest('bytes % not yet implemented on Py3.0-3.4')
- b = bytes(b'hello, %b!')
- orig = b
- b %= b'world'
- self.assertEqual(b, b'hello, world!')
- self.assertEqual(orig, b'hello, %b!')
- self.assertFalse(b is orig)
+
+ # b = bytes(b'hello, %b!')
+ # orig = b
+ # b %= b'world'
+ # self.assertEqual(b, b'hello, world!')
+ # self.assertEqual(orig, b'hello, %b!')
+ # self.assertFalse(b is orig)
+
b = bytes(b'%s / 100 = %d%%')
b %= (b'seventy-nine', 79)
self.assertEqual(b, b'seventy-nine / 100 = 79%')
- @unittest.expectedFailure
- def test_mod_pep_461(self):
- """
- Test for the PEP 461 functionality (resurrection of %s formatting for
- bytes).
- """
- b1 = bytes(b'abc%b')
- b2 = b1 % b'def'
- self.assertEqual(b2, b'abcdef')
- self.assertTrue(isinstance(b2, bytes))
- self.assertEqual(type(b2), bytes)
- b3 = b1 % bytes(b'def')
- self.assertEqual(b3, b'abcdef')
- self.assertTrue(isinstance(b3, bytes))
- self.assertEqual(type(b3), bytes)
-
- # %s is supported for backwards compatibility with Py2's str
- b4 = bytes(b'abc%s')
- b5 = b4 % b'def'
- self.assertEqual(b5, b'abcdef')
- self.assertTrue(isinstance(b5, bytes))
- self.assertEqual(type(b5), bytes)
- b6 = b4 % bytes(b'def')
- self.assertEqual(b6, b'abcdef')
- self.assertTrue(isinstance(b6, bytes))
- self.assertEqual(type(b6), bytes)
-
- self.assertEqual(bytes(b'%c') % 48, b'0')
- self.assertEqual(bytes(b'%c') % b'a', b'a')
-
- # For any numeric code %x, formatting of
- # b"%x" % val
- # is supposed to be equivalent to
- # ("%x" % val).encode("ascii")
- for code in b'xdiouxXeEfFgG':
- pct_str = u"%" + code.decode('ascii')
- for val in range(300):
- self.assertEqual(bytes(b"%" + code) % val,
- (pct_str % val).encode("ascii"))
-
- with self.assertRaises(TypeError):
- bytes(b'%b') % 3.14
- # Traceback (most recent call last):
- # ...
- # TypeError: b'%b' does not accept 'float'
-
- with self.assertRaises(TypeError):
- bytes(b'%b') % 'hello world!'
- # Traceback (most recent call last):
- # ...
- # TypeError: b'%b' does not accept 'str'
-
- self.assertEqual(bytes(b'%a') % 3.14, b'3.14')
-
- self.assertEqual(bytes(b'%a') % b'abc', b"b'abc'")
- self.assertEqual(bytes(b'%a') % bytes(b'abc'), b"b'abc'")
-
- self.assertEqual(bytes(b'%a') % 'def', b"'def'")
-
- # PEP 461 specifes that %r is not supported.
- with self.assertRaises(TypeError):
- bytes(b'%r' % b'abc')
+ b = bytes(b'%s / 100 = %d%%')
+ b %= (bytes(b'seventy-nine'), 79)
+ self.assertEqual(b, b'seventy-nine / 100 = 79%')
- with self.assertRaises(TypeError):
- bytes(b'%r' % 'abc')
+ # def test_mod_pep_461(self):
+ # """
+ # Test for the PEP 461 functionality (resurrection of %s formatting for
+ # bytes).
+ # """
+ # b1 = bytes(b'abc%b')
+ # b2 = b1 % b'def'
+ # self.assertEqual(b2, b'abcdef')
+ # self.assertTrue(isinstance(b2, bytes))
+ # self.assertEqual(type(b2), bytes)
+ # b3 = b1 % bytes(b'def')
+ # self.assertEqual(b3, b'abcdef')
+ # self.assertTrue(isinstance(b3, bytes))
+ # self.assertEqual(type(b3), bytes)
+ #
+ # # %s is supported for backwards compatibility with Py2's str
+ # b4 = bytes(b'abc%s')
+ # b5 = b4 % b'def'
+ # self.assertEqual(b5, b'abcdef')
+ # self.assertTrue(isinstance(b5, bytes))
+ # self.assertEqual(type(b5), bytes)
+ # b6 = b4 % bytes(b'def')
+ # self.assertEqual(b6, b'abcdef')
+ # self.assertTrue(isinstance(b6, bytes))
+ # self.assertEqual(type(b6), bytes)
+ #
+ # self.assertEqual(bytes(b'%c') % 48, b'0')
+ # self.assertEqual(bytes(b'%c') % b'a', b'a')
+ #
+ # # For any numeric code %x, formatting of
+ # # b"%x" % val
+ # # is supposed to be equivalent to
+ # # ("%x" % val).encode("ascii")
+ # for code in b'xdiouxXeEfFgG':
+ # bytechar = bytes([code])
+ # pct_str = u"%" + bytechar.decode('ascii')
+ # for val in range(300):
+ # self.assertEqual(bytes(b"%" + bytechar) % val,
+ # (pct_str % val).encode("ascii"))
+ #
+ # with self.assertRaises(TypeError):
+ # bytes(b'%b') % 3.14
+ # # Traceback (most recent call last):
+ # # ...
+ # # TypeError: b'%b' does not accept 'float'
+ #
+ # with self.assertRaises(TypeError):
+ # bytes(b'%b') % 'hello world!'
+ # # Traceback (most recent call last):
+ # # ...
+ # # TypeError: b'%b' does not accept 'str'
+ #
+ # self.assertEqual(bytes(b'%a') % 3.14, b'3.14')
+ #
+ # self.assertEqual(bytes(b'%a') % b'abc', b"b'abc'")
+ # self.assertEqual(bytes(b'%a') % bytes(b'abc'), b"b'abc'")
+ #
+ # self.assertEqual(bytes(b'%a') % 'def', b"'def'")
+ #
+ # # PEP 461 was updated after an Py3.5 alpha release to specify that %r is now supported
+ # # for compatibility: http://legacy.python.org/dev/peps/pep-0461/#id16
+ # assert bytes(b'%r' % b'abc') == bytes(b'%a' % b'abc')
+ #
+ # # with self.assertRaises(TypeError):
+ # # bytes(b'%r' % 'abc')
@expectedFailurePY2
def test_multiple_inheritance(self):
"""
Issue #96 (for newbytes instead of newobject)
"""
- import collections
+ if utils.PY2:
+ from collections import Container
+ else:
+ from collections.abc import Container
class Base(bytes):
pass
- class Foo(Base, collections.Container):
+ class Foo(Base, Container):
def __contains__(self, item):
return False
@@ -674,6 +739,48 @@ def test_surrogateescape_decoding(self):
self.assertTrue(isinstance(decoded, str))
self.assertEqual(b, decoded.encode('utf-8', 'surrogateescape'))
+ def test_issue_171_part_a(self):
+ b1 = str(u'abc \u0123 do re mi').encode(u'utf_8')
+ b2 = bytes(u'abc \u0123 do re mi', u'utf_8')
+ b3 = bytes(str(u'abc \u0123 do re mi'), u'utf_8')
+
+ @expectedFailurePY2
+ def test_issue_171_part_b(self):
+ """
+ Tests whether:
+ >>> nativebytes = bytes ; nativestr = str ; from builtins import *
+ >>> nativebytes(bytes(b'asdf'))[0] == b'a' == b'asdf'
+ """
+ nativebytes = type(b'')
+ nativestr = type('')
+ b = nativebytes(bytes(b'asdf'))
+ self.assertEqual(b, b'asdf')
+
+ def test_cast_to_bytes(self):
+ """
+ Tests whether __bytes__ method is called
+ """
+
+ class TestObject:
+ def __bytes__(self):
+ return b'asdf'
+
+ self.assertEqual(bytes(TestObject()), b'asdf')
+
+ def test_cast_to_bytes_iter_precedence(self):
+ """
+ Tests that call to __bytes__ is preferred to iteration
+ """
+
+ class TestObject:
+ def __bytes__(self):
+ return b'asdf'
+
+ def __iter__(self):
+ return iter(b'hjkl')
+
+ self.assertEqual(bytes(TestObject()), b'asdf')
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/test_future/test_chainmap.py b/tests/test_future/test_chainmap.py
new file mode 100644
index 00000000..2440401b
--- /dev/null
+++ b/tests/test_future/test_chainmap.py
@@ -0,0 +1,160 @@
+"""
+Tests for the future.standard_library module
+"""
+
+from __future__ import absolute_import, print_function
+from future import standard_library
+from future import utils
+from future.tests.base import unittest, CodeHandler, expectedFailurePY2
+
+import sys
+import tempfile
+import os
+import copy
+import textwrap
+from subprocess import CalledProcessError
+
+
+class TestChainMap(CodeHandler):
+
+ def setUp(self):
+ self.interpreter = sys.executable
+ standard_library.install_aliases()
+ super(TestChainMap, self).setUp()
+
+ def tearDown(self):
+ # standard_library.remove_hooks()
+ pass
+
+ @staticmethod
+ def simple_cm():
+ from collections import ChainMap
+ c = ChainMap()
+ c['one'] = 1
+ c['two'] = 2
+
+ cc = c.new_child()
+ cc['one'] = 'one'
+
+ return c, cc
+
+
+ def test_repr(self):
+ c, cc = TestChainMap.simple_cm()
+
+ order1 = "ChainMap({'one': 'one'}, {'one': 1, 'two': 2})"
+ order2 = "ChainMap({'one': 'one'}, {'two': 2, 'one': 1})"
+ assert repr(cc) in [order1, order2]
+
+
+ def test_recursive_repr(self):
+ """
+ Test for degnerative recursive cases. Very unlikely in
+ ChainMaps. But all must bow before the god of testing coverage.
+ """
+ from collections import ChainMap
+ c = ChainMap()
+ c['one'] = c
+ assert repr(c) == "ChainMap({'one': ...})"
+
+
+ def test_get(self):
+ c, cc = TestChainMap.simple_cm()
+
+ assert cc.get('two') == 2
+ assert cc.get('three') == None
+ assert cc.get('three', 'notthree') == 'notthree'
+
+
+ def test_bool(self):
+ from collections import ChainMap
+ c = ChainMap()
+ assert not(bool(c))
+
+ c['one'] = 1
+ c['two'] = 2
+ assert bool(c)
+
+ cc = c.new_child()
+ cc['one'] = 'one'
+ assert cc
+
+
+ def test_fromkeys(self):
+ from collections import ChainMap
+ keys = 'a b c'.split()
+ c = ChainMap.fromkeys(keys)
+ assert len(c) == 3
+ assert c['a'] == None
+ assert c['b'] == None
+ assert c['c'] == None
+
+
+ def test_copy(self):
+ c, cc = TestChainMap.simple_cm()
+ new_cc = cc.copy()
+ assert new_cc is not cc
+ assert sorted(new_cc.items()) == sorted(cc.items())
+
+
+ def test_parents(self):
+ c, cc = TestChainMap.simple_cm()
+
+ new_c = cc.parents
+ assert c is not new_c
+ assert len(new_c) == 2
+ assert new_c['one'] == c['one']
+ assert new_c['two'] == c['two']
+
+
+ def test_delitem(self):
+ c, cc = TestChainMap.simple_cm()
+
+ with self.assertRaises(KeyError):
+ del cc['two']
+
+ del cc['one']
+ assert len(cc) == 2
+ assert cc['one'] == 1
+ assert cc['two'] == 2
+
+
+ def test_popitem(self):
+ c, cc = TestChainMap.simple_cm()
+
+ assert cc.popitem() == ('one', 'one')
+
+ with self.assertRaises(KeyError):
+ cc.popitem()
+
+
+ def test_pop(self):
+ c, cc = TestChainMap.simple_cm()
+
+ assert cc.pop('one') == 'one'
+
+ with self.assertRaises(KeyError):
+ cc.pop('two')
+
+ assert len(cc) == 2
+
+
+ def test_clear(self):
+ c, cc = TestChainMap.simple_cm()
+
+ cc.clear()
+ assert len(cc) == 2
+ assert cc['one'] == 1
+ assert cc['two'] == 2
+
+
+ def test_missing(self):
+
+ c, cc = TestChainMap.simple_cm()
+
+ with self.assertRaises(KeyError):
+ cc['clown']
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/test_future/test_count.py b/tests/test_future/test_count.py
new file mode 100644
index 00000000..cc849bd5
--- /dev/null
+++ b/tests/test_future/test_count.py
@@ -0,0 +1,57 @@
+# -*- coding: utf-8 -*-
+"""
+Tests for the backported class:`range` class.
+"""
+from itertools import count as it_count
+
+from future.backports.misc import count
+from future.tests.base import unittest, skip26
+
+
+class CountTest(unittest.TestCase):
+
+ """Test the count function."""
+
+ def _test_count_func(self, func):
+ self.assertEqual(next(func(1)), 1)
+ self.assertEqual(next(func(start=1)), 1)
+
+ c = func()
+ self.assertEqual(next(c), 0)
+ self.assertEqual(next(c), 1)
+ self.assertEqual(next(c), 2)
+ c = func(1, 1)
+ self.assertEqual(next(c), 1)
+ self.assertEqual(next(c), 2)
+ c = func(step=1)
+ self.assertEqual(next(c), 0)
+ self.assertEqual(next(c), 1)
+ c = func(start=1, step=1)
+ self.assertEqual(next(c), 1)
+ self.assertEqual(next(c), 2)
+
+ c = func(-1)
+ self.assertEqual(next(c), -1)
+ self.assertEqual(next(c), 0)
+ self.assertEqual(next(c), 1)
+ c = func(1, -1)
+ self.assertEqual(next(c), 1)
+ self.assertEqual(next(c), 0)
+ self.assertEqual(next(c), -1)
+ c = func(-1, -1)
+ self.assertEqual(next(c), -1)
+ self.assertEqual(next(c), -2)
+ self.assertEqual(next(c), -3)
+
+ def test_count(self):
+ """Test the count function."""
+ self._test_count_func(count)
+
+ @skip26
+ def test_own_count(self):
+ """Test own count implementation."""
+ self._test_count_func(it_count)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/test_future/test_decorators.py b/tests/test_future/test_decorators.py
index 428fb8a3..9ec2bb37 100644
--- a/tests/test_future/test_decorators.py
+++ b/tests/test_future/test_decorators.py
@@ -36,14 +36,14 @@ def __str__(self):
assert str(a) == str(b)
def test_implements_iterator(self):
-
+
@implements_iterator
class MyIter(object):
def __next__(self):
return 'Next!'
def __iter__(self):
return self
-
+
itr = MyIter()
self.assertEqual(next(itr), 'Next!')
diff --git a/tests/test_future/test_dict.py b/tests/test_future/test_dict.py
index 68856828..ff9dd4ab 100644
--- a/tests/test_future/test_dict.py
+++ b/tests/test_future/test_dict.py
@@ -111,12 +111,15 @@ def test_multiple_inheritance(self):
"""
Issue #96 (for newdict instead of newobject)
"""
- import collections
+ if utils.PY2:
+ from collections import Container
+ else:
+ from collections.abc import Container
class Base(dict):
pass
- class Foo(Base, collections.Container):
+ class Foo(Base, Container):
def __contains__(self, item):
return False
diff --git a/tests/test_future/test_email_generation.py b/tests/test_future/test_email_generation.py
new file mode 100644
index 00000000..10e61138
--- /dev/null
+++ b/tests/test_future/test_email_generation.py
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+"""Tests for email generation."""
+
+from __future__ import unicode_literals
+
+from future.backports.email.mime.multipart import MIMEMultipart
+from future.backports.email.mime.text import MIMEText
+from future.backports.email.utils import formatdate
+from future.tests.base import unittest
+
+
+class EmailGenerationTests(unittest.TestCase):
+ def test_email_custom_header_can_contain_unicode(self):
+ msg = MIMEMultipart()
+ alternative = MIMEMultipart('alternative')
+ alternative.attach(MIMEText('Plain content with Únicødê', _subtype='plain', _charset='utf-8'))
+ alternative.attach(MIMEText('HTML content with Únicødê', _subtype='html', _charset='utf-8'))
+ msg.attach(alternative)
+
+ msg['Subject'] = 'Subject with Únicødê'
+ msg['From'] = 'sender@test.com'
+ msg['To'] = 'recipient@test.com'
+ msg['Date'] = formatdate(None, localtime=True)
+ msg['Message-ID'] = 'anIdWithÚnicødêForThisEmail'
+
+ msg_lines = msg.as_string().split('\n')
+ self.assertEqual(msg_lines[2], 'Subject: =?utf-8?b?U3ViamVjdCB3aXRoIMOabmljw7hkw6o=?=')
+ self.assertEqual(msg_lines[6], 'Message-ID: =?utf-8?b?YW5JZFdpdGjDmm5pY8O4ZMOqRm9yVGhpc0VtYWls?=')
+ self.assertEqual(msg_lines[17], 'UGxhaW4gY29udGVudCB3aXRoIMOabmljw7hkw6o=')
+ self.assertEqual(msg_lines[24], 'SFRNTCBjb250ZW50IHdpdGggw5puaWPDuGTDqg==')
diff --git a/tests/test_future/test_email_multipart.py b/tests/test_future/test_email_multipart.py
new file mode 100644
index 00000000..cbd93b89
--- /dev/null
+++ b/tests/test_future/test_email_multipart.py
@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+"""Tests for multipart emails."""
+
+from future.tests.base import unittest
+import future.backports.email as email
+import future.backports.email.mime.multipart
+from future.builtins import list
+
+class EmailMultiPartTests(unittest.TestCase):
+ """Tests for handling multipart email Messages."""
+
+ def test_multipart_serialize_without_boundary(self):
+ """Tests that serializing an empty multipart email does not fail."""
+ multipart_message = email.mime.multipart.MIMEMultipart()
+ self.assertIsNot(multipart_message.as_string(), None)
+
+ def test_multipart_set_boundary_does_not_change_header_type(self):
+ """
+ Tests that Message.set_boundary() does not cause Python2 errors.
+
+ In particular, tests that set_boundary does not cause the type of the
+ message headers list to be changed from the future built-in list.
+ """
+ multipart_message = email.mime.multipart.MIMEMultipart()
+ headers_type = type(multipart_message._headers)
+ self.assertEqual(headers_type, type(list()))
+
+ boundary = '===============6387699881409002085=='
+ multipart_message.set_boundary(boundary)
+ headers_type = type(multipart_message._headers)
+ self.assertEqual(headers_type, type(list()))
diff --git a/tests/test_future/test_futurize.py b/tests/test_future/test_futurize.py
index a50e662c..c3696a54 100644
--- a/tests/test_future/test_futurize.py
+++ b/tests/test_future/test_futurize.py
@@ -123,6 +123,17 @@ def test_encoding_comments_kept_at_top(self):
"""
self.convert_check(before, after)
+ def test_multiline_future_import(self):
+ """
+ Issue #113: don't crash if a future import has multiple lines
+ """
+ text = """
+ from __future__ import (
+ division
+ )
+ """
+ self.convert(text)
+
def test_shebang_blank_with_future_division_import(self):
"""
Issue #43: Is shebang line preserved as the first
@@ -425,6 +436,28 @@ def test_import_builtins(self):
"""
self.convert_check(before, after, ignore_imports=False, run=False)
+ @expectedFailurePY26
+ def test_input_without_import(self):
+ before = """
+ a = input()
+ """
+ after = """
+ from builtins import input
+ a = eval(input())
+ """
+ self.convert_check(before, after, ignore_imports=False, run=False)
+
+ def test_input_with_import(self):
+ before = """
+ from builtins import input
+ a = input()
+ """
+ after = """
+ from builtins import input
+ a = input()
+ """
+ self.convert_check(before, after, ignore_imports=False, run=False)
+
def test_xrange(self):
"""
The ``from builtins import range`` line was being added to the
@@ -441,7 +474,7 @@ def test_xrange(self):
pass
"""
self.convert_check(before, after, ignore_imports=False)
-
+
def test_source_coding_utf8(self):
"""
Tests to ensure that the source coding line is not corrupted or
@@ -506,13 +539,13 @@ def test_apply(self):
before = '''
def addup(*x):
return sum(x)
-
+
assert apply(addup, (10,20)) == 30
'''
after = """
def addup(*x):
return sum(x)
-
+
assert addup(*(10,20)) == 30
"""
self.convert_check(before, after)
@@ -631,7 +664,9 @@ def test_renamed_modules(self):
import pickle
import io
"""
- self.convert_check(before, after)
+ # We can't run the converted code because configparser may
+ # not be there.
+ self.convert_check(before, after, run=False)
@unittest.skip('Not working yet ...')
def test_urllib_refactor(self):
@@ -649,7 +684,7 @@ def test_urllib_refactor(self):
from future import standard_library
standard_library.install_aliases()
import urllib.request
-
+
URL = 'http://pypi.python.org/pypi/future/json'
package = 'future'
r = urllib.request.urlopen(URL.format(package))
@@ -1032,13 +1067,13 @@ def test___future___import_position(self):
#
# another comment
#
-
+
CONSTANTS = [ 0, 01, 011, 0111, 012, 02, 021, 0211, 02111, 013 ]
_RN_LETTERS = "IVXLCDM"
-
+
def my_func(value):
pass
-
+
''' Docstring-like comment here '''
"""
self.convert(code)
@@ -1168,18 +1203,82 @@ def test_safe_division(self):
after futurization.
"""
before = """
+ import random
+ class fraction(object):
+ numer = 0
+ denom = 0
+ def __init__(self, numer, denom):
+ self.numer = numer
+ self.denom = denom
+
+ def total_count(self):
+ return self.numer * 50
+
x = 3 / 2
y = 3. / 2
+ foo = list(range(100))
assert x == 1 and isinstance(x, int)
assert y == 1.5 and isinstance(y, float)
+ a = 1 + foo[len(foo) / 2]
+ b = 1 + foo[len(foo) * 3 / 4]
+ assert a == 51
+ assert b == 76
+ r = random.randint(0, 1000) * 1.0 / 1000
+ output = { "SUCCESS": 5, "TOTAL": 10 }
+ output["SUCCESS"] * 100 / output["TOTAL"]
+ obj = fraction(1, 50)
+ val = float(obj.numer) / obj.denom * 1e-9
+ obj.numer * obj.denom / val
+ obj.total_count() * val / 100
+ obj.numer / obj.denom * 1e-9
+ obj.numer / (obj.denom * 1e-9)
+ obj.numer / obj.denom / 1e-9
+ obj.numer / (obj.denom / 1e-9)
+ original_numer = 1
+ original_denom = 50
+ 100 * abs(obj.numer - original_numer) / float(max(obj.denom, original_denom))
+ 100 * abs(obj.numer - original_numer) / max(obj.denom, original_denom)
+ float(original_numer) * float(original_denom) / float(obj.numer)
"""
after = """
from __future__ import division
from past.utils import old_div
+ import random
+ class fraction(object):
+ numer = 0
+ denom = 0
+ def __init__(self, numer, denom):
+ self.numer = numer
+ self.denom = denom
+
+ def total_count(self):
+ return self.numer * 50
+
x = old_div(3, 2)
- y = old_div(3., 2)
+ y = 3. / 2
+ foo = list(range(100))
assert x == 1 and isinstance(x, int)
assert y == 1.5 and isinstance(y, float)
+ a = 1 + foo[old_div(len(foo), 2)]
+ b = 1 + foo[old_div(len(foo) * 3, 4)]
+ assert a == 51
+ assert b == 76
+ r = random.randint(0, 1000) * 1.0 / 1000
+ output = { "SUCCESS": 5, "TOTAL": 10 }
+ old_div(output["SUCCESS"] * 100, output["TOTAL"])
+ obj = fraction(1, 50)
+ val = float(obj.numer) / obj.denom * 1e-9
+ old_div(obj.numer * obj.denom, val)
+ old_div(obj.total_count() * val, 100)
+ old_div(obj.numer, obj.denom) * 1e-9
+ old_div(obj.numer, (obj.denom * 1e-9))
+ old_div(old_div(obj.numer, obj.denom), 1e-9)
+ old_div(obj.numer, (old_div(obj.denom, 1e-9)))
+ original_numer = 1
+ original_denom = 50
+ 100 * abs(obj.numer - original_numer) / float(max(obj.denom, original_denom))
+ old_div(100 * abs(obj.numer - original_numer), max(obj.denom, original_denom))
+ float(original_numer) * float(original_denom) / float(obj.numer)
"""
self.convert_check(before, after)
@@ -1292,6 +1391,7 @@ def test_open(self):
"""
self.convert_check(before, after, conservative=True)
+
class TestFuturizeAllImports(CodeHandler):
"""
Tests "futurize --all-imports".
@@ -1309,14 +1409,14 @@ def test_all_imports(self):
print('Hello')
"""
after = """
- from __future__ import unicode_literals
- from __future__ import print_function
- from __future__ import division
from __future__ import absolute_import
+ from __future__ import division
+ from __future__ import print_function
+ from __future__ import unicode_literals
from future import standard_library
standard_library.install_aliases()
- from builtins import range
from builtins import *
+ from builtins import range
import math
import os
l = list(range(10))
@@ -1326,7 +1426,7 @@ def test_all_imports(self):
pass
print('Hello')
"""
- self.convert_check(before, after, all_imports=True)
+ self.convert_check(before, after, all_imports=True, ignore_imports=False)
if __name__ == '__main__':
diff --git a/tests/test_future/test_httplib.py b/tests/test_future/test_httplib.py
index 968e9339..a1e2b19a 100644
--- a/tests/test_future/test_httplib.py
+++ b/tests/test_future/test_httplib.py
@@ -197,7 +197,7 @@ def test_bad_status_repr(self):
if not utils.PY3:
self.assertEqual(repr(exc), '''BadStatusLine("u\'\'",)''')
else:
- self.assertEqual(repr(exc), '''BadStatusLine("\'\'",)''')
+ self.assertIn(repr(exc), ('''BadStatusLine("''",)''', '''BadStatusLine("''")'''))
def test_partial_reads(self):
# if we have a length, the system knows when to close itself
diff --git a/tests/test_future/test_int.py b/tests/test_future/test_int.py
index f1d9c5d8..573a0d53 100644
--- a/tests/test_future/test_int.py
+++ b/tests/test_future/test_int.py
@@ -265,12 +265,17 @@ def test_small_ints(self):
def test_no_args(self):
self.assertEqual(int(), 0)
- def test_keyword_args(self):
+ @unittest.skipIf(sys.version_info >= (3, 7),
+ "The first parameter must be positional with Python >= 3.7"
+ )
+ def test_x_keyword_arg(self):
# Test invoking int() using keyword arguments.
self.assertEqual(int(x=1.2), 1)
- self.assertEqual(int('100', base=2), 4)
self.assertEqual(int(x='100', base=2), 4)
+ def text_base_keyword_arg(self):
+ self.assertEqual(int('100', base=2), 4)
+
def test_newint_plus_float(self):
minutes = int(100)
second = 0.0
@@ -339,7 +344,7 @@ def __int__(self):
class Foo3(int):
def __int__(self):
- return self
+ return self.real
class Foo4(int):
def __int__(self):
@@ -1064,12 +1069,12 @@ def test_multiple_inheritance(self):
"""
Issue #96 (for newint instead of newobject)
"""
- import collections
+ import collections.abc
class Base(int):
pass
- class Foo(Base, collections.Container):
+ class Foo(Base, collections.abc.Container):
def __add__(self, other):
return 0
diff --git a/tests/test_future/test_libfuturize_fixers.py b/tests/test_future/test_libfuturize_fixers.py
index c7fa8ddc..2146d1f2 100644
--- a/tests/test_future/test_libfuturize_fixers.py
+++ b/tests/test_future/test_libfuturize_fixers.py
@@ -25,7 +25,7 @@
# grammar_path = os.path.join(test_dir, "..", "Grammar.txt")
# grammar = driver.load_grammar(grammar_path)
# driver = driver.Driver(grammar, convert=pytree.convert)
-#
+#
# def parse_string(string):
# return driver.parse_string(reformat(string), debug=True)
@@ -118,118 +118,118 @@ def assert_runs_after(self, *names):
############### EDIT the tests below ...
-#
+#
# class Test_ne(FixerTestCase):
# fixer = "ne"
-#
+#
# def test_basic(self):
# b = """if x <> y:
# pass"""
-#
+#
# a = """if x != y:
# pass"""
# self.check(b, a)
-#
-#
+#
+#
# class Test_print(FixerTestCase):
# fixer = "print_"
-#
+#
# def test_print(self):
# b = """print 'Hello world'"""
# a = """from __future__ import print_function\nprint('Hello world')"""
# self.check(b, a)
-#
-#
+#
+#
# class Test_apply(FixerTestCase):
# fixer = "apply"
-#
+#
# def test_1(self):
# b = """x = apply(f, g + h)"""
# a = """x = f(*g + h)"""
# self.check(b, a)
-#
-#
+#
+#
# class Test_intern(FixerTestCase):
# fixer = "intern"
-#
+#
# def test_prefix_preservation(self):
# b = """x = intern( a )"""
# a = """import sys\nx = sys.intern( a )"""
# self.check(b, a)
-#
+#
# b = """y = intern("b" # test
# )"""
# a = """import sys\ny = sys.intern("b" # test
# )"""
# self.check(b, a)
-#
+#
# b = """z = intern(a+b+c.d, )"""
# a = """import sys\nz = sys.intern(a+b+c.d, )"""
# self.check(b, a)
-#
+#
# def test(self):
# b = """x = intern(a)"""
# a = """import sys\nx = sys.intern(a)"""
# self.check(b, a)
-#
+#
# b = """z = intern(a+b+c.d,)"""
# a = """import sys\nz = sys.intern(a+b+c.d,)"""
# self.check(b, a)
-#
+#
# b = """intern("y%s" % 5).replace("y", "")"""
# a = """import sys\nsys.intern("y%s" % 5).replace("y", "")"""
# self.check(b, a)
-#
+#
# # These should not be refactored
-#
+#
# def test_unchanged(self):
# s = """intern(a=1)"""
# self.unchanged(s)
-#
+#
# s = """intern(f, g)"""
# self.unchanged(s)
-#
+#
# s = """intern(*h)"""
# self.unchanged(s)
-#
+#
# s = """intern(**i)"""
# self.unchanged(s)
-#
+#
# s = """intern()"""
# self.unchanged(s)
-#
+#
# class Test_reduce(FixerTestCase):
# fixer = "reduce"
-#
+#
# def test_simple_call(self):
# b = "reduce(a, b, c)"
# a = "from functools import reduce\nreduce(a, b, c)"
# self.check(b, a)
-#
+#
# def test_bug_7253(self):
# # fix_tuple_params was being bad and orphaning nodes in the tree.
# b = "def x(arg): reduce(sum, [])"
# a = "from functools import reduce\ndef x(arg): reduce(sum, [])"
# self.check(b, a)
-#
+#
# def test_call_with_lambda(self):
# b = "reduce(lambda x, y: x + y, seq)"
# a = "from functools import reduce\nreduce(lambda x, y: x + y, seq)"
# self.check(b, a)
-#
+#
# def test_unchanged(self):
# s = "reduce(a)"
# self.unchanged(s)
-#
+#
# s = "reduce(a, b=42)"
# self.unchanged(s)
-#
+#
# s = "reduce(a, b, c, d)"
# self.unchanged(s)
-#
+#
# s = "reduce(**c)"
# self.unchanged(s)
-#
+#
# s = "reduce()"
# self.unchanged(s)
@@ -307,6 +307,37 @@ def test_trailing_comma_3(self):
a = """print(1, end=' ')"""
self.check(b, a)
+ def test_trailing_comma_4(self):
+ b = """print "a ","""
+ a = """print("a ", end=' ')"""
+ self.check(b, a)
+
+ def test_trailing_comma_5(self):
+ b = r"""print "b\t","""
+ a = r"""print("b\t", end='')"""
+ self.check(b, a)
+
+ def test_trailing_comma_6(self):
+ b = r"""print "c\n","""
+ a = r"""print("c\n", end='')"""
+ self.check(b, a)
+
+ def test_trailing_comma_7(self):
+ b = r"""print "d\r","""
+ a = r"""print("d\r", end='')"""
+ self.check(b, a)
+
+ def test_trailing_comma_8(self):
+ b = r"""print "%s\n" % (1,),"""
+ a = r"""print("%s\n" % (1,), end='')"""
+ self.check(b, a)
+
+
+ def test_trailing_comma_9(self):
+ b = r"""print r"e\n","""
+ a = r"""print(r"e\n", end=' ')"""
+ self.check(b, a)
+
# >> stuff
def test_vargs_without_trailing_comma(self):
@@ -341,96 +372,96 @@ def test_with_future_print_function(self):
# class Test_exec(FixerTestCase):
# fixer = "exec"
-#
+#
# def test_prefix_preservation(self):
# b = """ exec code in ns1, ns2"""
# a = """ exec(code, ns1, ns2)"""
# self.check(b, a)
-#
+#
# def test_basic(self):
# b = """exec code"""
# a = """exec(code)"""
# self.check(b, a)
-#
+#
# def test_with_globals(self):
# b = """exec code in ns"""
# a = """exec(code, ns)"""
# self.check(b, a)
-#
+#
# def test_with_globals_locals(self):
# b = """exec code in ns1, ns2"""
# a = """exec(code, ns1, ns2)"""
# self.check(b, a)
-#
+#
# def test_complex_1(self):
# b = """exec (a.b()) in ns"""
# a = """exec((a.b()), ns)"""
# self.check(b, a)
-#
+#
# def test_complex_2(self):
# b = """exec a.b() + c in ns"""
# a = """exec(a.b() + c, ns)"""
# self.check(b, a)
-#
+#
# # These should not be touched
-#
+#
# def test_unchanged_1(self):
# s = """exec(code)"""
# self.unchanged(s)
-#
+#
# def test_unchanged_2(self):
# s = """exec (code)"""
# self.unchanged(s)
-#
+#
# def test_unchanged_3(self):
# s = """exec(code, ns)"""
# self.unchanged(s)
-#
+#
# def test_unchanged_4(self):
# s = """exec(code, ns1, ns2)"""
# self.unchanged(s)
-#
+#
# class Test_repr(FixerTestCase):
# fixer = "repr"
-#
+#
# def test_prefix_preservation(self):
# b = """x = `1 + 2`"""
# a = """x = repr(1 + 2)"""
# self.check(b, a)
-#
+#
# def test_simple_1(self):
# b = """x = `1 + 2`"""
# a = """x = repr(1 + 2)"""
# self.check(b, a)
-#
+#
# def test_simple_2(self):
# b = """y = `x`"""
# a = """y = repr(x)"""
# self.check(b, a)
-#
+#
# def test_complex(self):
# b = """z = `y`.__repr__()"""
# a = """z = repr(y).__repr__()"""
# self.check(b, a)
-#
+#
# def test_tuple(self):
# b = """x = `1, 2, 3`"""
# a = """x = repr((1, 2, 3))"""
# self.check(b, a)
-#
+#
# def test_nested(self):
# b = """x = `1 + `2``"""
# a = """x = repr(1 + repr(2))"""
# self.check(b, a)
-#
+#
# def test_nested_tuples(self):
# b = """x = `1, 2 + `3, 4``"""
# a = """x = repr((1, 2 + repr((3, 4))))"""
# self.check(b, a)
-#
+#
# class Test_except(FixerTestCase):
# fixer = "except"
-#
+#
# def test_prefix_preservation(self):
# b = """
# try:
@@ -443,7 +474,7 @@ def test_with_future_print_function(self):
# except (RuntimeError, ImportError) as e:
# pass"""
# self.check(b, a)
-#
+#
# def test_simple(self):
# b = """
# try:
@@ -456,7 +487,7 @@ def test_with_future_print_function(self):
# except Foo as e:
# pass"""
# self.check(b, a)
-#
+#
# def test_simple_no_space_before_target(self):
# b = """
# try:
@@ -469,7 +500,7 @@ def test_with_future_print_function(self):
# except Foo as e:
# pass"""
# self.check(b, a)
-#
+#
# def test_tuple_unpack(self):
# b = """
# def foo():
@@ -479,7 +510,7 @@ def test_with_future_print_function(self):
# pass
# except ImportError, e:
# pass"""
-#
+#
# a = """
# def foo():
# try:
@@ -490,28 +521,28 @@ def test_with_future_print_function(self):
# except ImportError as e:
# pass"""
# self.check(b, a)
-#
+#
# def test_multi_class(self):
# b = """
# try:
# pass
# except (RuntimeError, ImportError), e:
# pass"""
-#
+#
# a = """
# try:
# pass
# except (RuntimeError, ImportError) as e:
# pass"""
# self.check(b, a)
-#
+#
# def test_list_unpack(self):
# b = """
# try:
# pass
# except Exception, [a, b]:
# pass"""
-#
+#
# a = """
# try:
# pass
@@ -519,14 +550,14 @@ def test_with_future_print_function(self):
# [a, b] = xxx_todo_changeme.args
# pass"""
# self.check(b, a)
-#
+#
# def test_weird_target_1(self):
# b = """
# try:
# pass
# except Exception, d[5]:
# pass"""
-#
+#
# a = """
# try:
# pass
@@ -534,14 +565,14 @@ def test_with_future_print_function(self):
# d[5] = xxx_todo_changeme
# pass"""
# self.check(b, a)
-#
+#
# def test_weird_target_2(self):
# b = """
# try:
# pass
# except Exception, a.foo:
# pass"""
-#
+#
# a = """
# try:
# pass
@@ -549,14 +580,14 @@ def test_with_future_print_function(self):
# a.foo = xxx_todo_changeme
# pass"""
# self.check(b, a)
-#
+#
# def test_weird_target_3(self):
# b = """
# try:
# pass
# except Exception, a().foo:
# pass"""
-#
+#
# a = """
# try:
# pass
@@ -564,7 +595,7 @@ def test_with_future_print_function(self):
# a().foo = xxx_todo_changeme
# pass"""
# self.check(b, a)
-#
+#
# def test_bare_except(self):
# b = """
# try:
@@ -573,7 +604,7 @@ def test_with_future_print_function(self):
# pass
# except:
# pass"""
-#
+#
# a = """
# try:
# pass
@@ -582,7 +613,7 @@ def test_with_future_print_function(self):
# except:
# pass"""
# self.check(b, a)
-#
+#
# def test_bare_except_and_else_finally(self):
# b = """
# try:
@@ -595,7 +626,7 @@ def test_with_future_print_function(self):
# pass
# finally:
# pass"""
-#
+#
# a = """
# try:
# pass
@@ -608,7 +639,7 @@ def test_with_future_print_function(self):
# finally:
# pass"""
# self.check(b, a)
-#
+#
# def test_multi_fixed_excepts_before_bare_except(self):
# b = """
# try:
@@ -619,7 +650,7 @@ def test_with_future_print_function(self):
# pass
# except:
# pass"""
-#
+#
# a = """
# try:
# pass
@@ -630,7 +661,7 @@ def test_with_future_print_function(self):
# except:
# pass"""
# self.check(b, a)
-#
+#
# def test_one_line_suites(self):
# b = """
# try: raise TypeError
@@ -676,9 +707,9 @@ def test_with_future_print_function(self):
# finally: done()
# """
# self.check(b, a)
-#
+#
# # These should not be touched:
-#
+#
# def test_unchanged_1(self):
# s = """
# try:
@@ -686,7 +717,7 @@ def test_with_future_print_function(self):
# except:
# pass"""
# self.unchanged(s)
-#
+#
# def test_unchanged_2(self):
# s = """
# try:
@@ -694,7 +725,7 @@ def test_with_future_print_function(self):
# except Exception:
# pass"""
# self.unchanged(s)
-#
+#
# def test_unchanged_3(self):
# s = """
# try:
@@ -702,194 +733,215 @@ def test_with_future_print_function(self):
# except (Exception, SystemExit):
# pass"""
# self.unchanged(s)
-#
-# class Test_raise(FixerTestCase):
-# fixer = "raise"
-#
-# def test_basic(self):
-# b = """raise Exception, 5"""
-# a = """raise Exception(5)"""
-# self.check(b, a)
-#
-# def test_prefix_preservation(self):
-# b = """raise Exception,5"""
-# a = """raise Exception(5)"""
-# self.check(b, a)
-#
-# b = """raise Exception, 5"""
-# a = """raise Exception(5)"""
-# self.check(b, a)
-#
-# def test_with_comments(self):
-# b = """raise Exception, 5 # foo"""
-# a = """raise Exception(5) # foo"""
-# self.check(b, a)
-#
-# b = """raise E, (5, 6) % (a, b) # foo"""
-# a = """raise E((5, 6) % (a, b)) # foo"""
-# self.check(b, a)
-#
-# b = """def foo():
-# raise Exception, 5, 6 # foo"""
-# a = """def foo():
-# raise Exception(5).with_traceback(6) # foo"""
-# self.check(b, a)
-#
-# def test_None_value(self):
-# b = """raise Exception(5), None, tb"""
-# a = """raise Exception(5).with_traceback(tb)"""
-# self.check(b, a)
-#
-# def test_tuple_value(self):
-# b = """raise Exception, (5, 6, 7)"""
-# a = """raise Exception(5, 6, 7)"""
-# self.check(b, a)
-#
-# def test_tuple_detection(self):
-# b = """raise E, (5, 6) % (a, b)"""
-# a = """raise E((5, 6) % (a, b))"""
-# self.check(b, a)
-#
-# def test_tuple_exc_1(self):
-# b = """raise (((E1, E2), E3), E4), V"""
-# a = """raise E1(V)"""
-# self.check(b, a)
-#
-# def test_tuple_exc_2(self):
-# b = """raise (E1, (E2, E3), E4), V"""
-# a = """raise E1(V)"""
-# self.check(b, a)
-#
-# # These should produce a warning
-#
-# def test_string_exc(self):
-# s = """raise 'foo'"""
-# self.warns_unchanged(s, "Python 3 does not support string exceptions")
-#
-# def test_string_exc_val(self):
-# s = """raise "foo", 5"""
-# self.warns_unchanged(s, "Python 3 does not support string exceptions")
-#
-# def test_string_exc_val_tb(self):
-# s = """raise "foo", 5, 6"""
-# self.warns_unchanged(s, "Python 3 does not support string exceptions")
-#
-# # These should result in traceback-assignment
-#
-# def test_tb_1(self):
-# b = """def foo():
-# raise Exception, 5, 6"""
-# a = """def foo():
-# raise Exception(5).with_traceback(6)"""
-# self.check(b, a)
-#
-# def test_tb_2(self):
-# b = """def foo():
-# a = 5
-# raise Exception, 5, 6
-# b = 6"""
-# a = """def foo():
-# a = 5
-# raise Exception(5).with_traceback(6)
-# b = 6"""
-# self.check(b, a)
-#
-# def test_tb_3(self):
-# b = """def foo():
-# raise Exception,5,6"""
-# a = """def foo():
-# raise Exception(5).with_traceback(6)"""
-# self.check(b, a)
-#
-# def test_tb_4(self):
-# b = """def foo():
-# a = 5
-# raise Exception,5,6
-# b = 6"""
-# a = """def foo():
-# a = 5
-# raise Exception(5).with_traceback(6)
-# b = 6"""
-# self.check(b, a)
-#
-# def test_tb_5(self):
-# b = """def foo():
-# raise Exception, (5, 6, 7), 6"""
-# a = """def foo():
-# raise Exception(5, 6, 7).with_traceback(6)"""
-# self.check(b, a)
-#
-# def test_tb_6(self):
-# b = """def foo():
-# a = 5
-# raise Exception, (5, 6, 7), 6
-# b = 6"""
-# a = """def foo():
-# a = 5
-# raise Exception(5, 6, 7).with_traceback(6)
-# b = 6"""
-# self.check(b, a)
-#
+
+class Test_raise(FixerTestCase):
+ fixer = "raise"
+
+ def test_basic(self):
+ b = """raise Exception, 5"""
+ a = """raise Exception(5)"""
+ self.check(b, a)
+
+ def test_prefix_preservation(self):
+ b = """raise Exception,5"""
+ a = """raise Exception(5)"""
+ self.check(b, a)
+
+ b = """raise Exception, 5"""
+ a = """raise Exception(5)"""
+ self.check(b, a)
+
+ def test_with_comments(self):
+ b = """raise Exception, 5 # foo"""
+ a = """raise Exception(5) # foo"""
+ self.check(b, a)
+
+ b = """def foo():
+ raise Exception, 5, 6 # foo"""
+ a = """def foo():
+ raise Exception(5).with_traceback(6) # foo"""
+ self.check(b, a)
+
+ def test_None_value(self):
+ b = """raise Exception(5), None, tb"""
+ a = """raise Exception(5).with_traceback(tb)"""
+ self.check(b, a)
+
+ def test_tuple_value(self):
+ b = """raise Exception, (5, 6, 7)"""
+ a = """raise Exception(5, 6, 7)"""
+ self.check(b, a)
+
+ def test_tuple_exc_1(self):
+ b = """raise (((E1, E2), E3), E4), 5"""
+ a = """raise E1(5)"""
+ self.check(b, a)
+
+ def test_tuple_exc_2(self):
+ b = """raise (E1, (E2, E3), E4), 5"""
+ a = """raise E1(5)"""
+ self.check(b, a)
+
+ def test_unknown_value(self):
+ b = """
+ raise E, V"""
+ a = """
+ from future.utils import raise_
+ raise_(E, V)"""
+ self.check(b, a)
+
+ def test_unknown_value_with_traceback_with_comments(self):
+ b = """
+ raise E, Func(arg1, arg2, arg3), tb # foo"""
+ a = """
+ from future.utils import raise_
+ raise_(E, Func(arg1, arg2, arg3), tb) # foo"""
+ self.check(b, a)
+
+ def test_unknown_value_with_indent(self):
+ b = """
+ while True:
+ print() # another expression in the same block triggers different parsing
+ raise E, V
+ """
+ a = """
+ from future.utils import raise_
+ while True:
+ print() # another expression in the same block triggers different parsing
+ raise_(E, V)
+ """
+ self.check(b, a)
+
+ # These should produce a warning
+
+ def test_string_exc(self):
+ s = """raise 'foo'"""
+ self.warns_unchanged(s, "Python 3 does not support string exceptions")
+
+ def test_string_exc_val(self):
+ s = """raise "foo", 5"""
+ self.warns_unchanged(s, "Python 3 does not support string exceptions")
+
+ def test_string_exc_val_tb(self):
+ s = """raise "foo", 5, 6"""
+ self.warns_unchanged(s, "Python 3 does not support string exceptions")
+
+ # These should result in traceback-assignment
+
+ def test_tb_1(self):
+ b = """def foo():
+ raise Exception, 5, 6"""
+ a = """def foo():
+ raise Exception(5).with_traceback(6)"""
+ self.check(b, a)
+
+ def test_tb_2(self):
+ b = """def foo():
+ a = 5
+ raise Exception, 5, 6
+ b = 6"""
+ a = """def foo():
+ a = 5
+ raise Exception(5).with_traceback(6)
+ b = 6"""
+ self.check(b, a)
+
+ def test_tb_3(self):
+ b = """def foo():
+ raise Exception,5,6"""
+ a = """def foo():
+ raise Exception(5).with_traceback(6)"""
+ self.check(b, a)
+
+ def test_tb_4(self):
+ b = """def foo():
+ a = 5
+ raise Exception,5,6
+ b = 6"""
+ a = """def foo():
+ a = 5
+ raise Exception(5).with_traceback(6)
+ b = 6"""
+ self.check(b, a)
+
+ def test_tb_5(self):
+ b = """def foo():
+ raise Exception, (5, 6, 7), 6"""
+ a = """def foo():
+ raise Exception(5, 6, 7).with_traceback(6)"""
+ self.check(b, a)
+
+ def test_tb_6(self):
+ b = """def foo():
+ a = 5
+ raise Exception, (5, 6, 7), 6
+ b = 6"""
+ a = """def foo():
+ a = 5
+ raise Exception(5, 6, 7).with_traceback(6)
+ b = 6"""
+ self.check(b, a)
+#
# class Test_throw(FixerTestCase):
# fixer = "throw"
-#
+#
# def test_1(self):
# b = """g.throw(Exception, 5)"""
# a = """g.throw(Exception(5))"""
# self.check(b, a)
-#
+#
# def test_2(self):
# b = """g.throw(Exception,5)"""
# a = """g.throw(Exception(5))"""
# self.check(b, a)
-#
+#
# def test_3(self):
# b = """g.throw(Exception, (5, 6, 7))"""
# a = """g.throw(Exception(5, 6, 7))"""
# self.check(b, a)
-#
+#
# def test_4(self):
# b = """5 + g.throw(Exception, 5)"""
# a = """5 + g.throw(Exception(5))"""
# self.check(b, a)
-#
+#
# # These should produce warnings
-#
+#
# def test_warn_1(self):
# s = """g.throw("foo")"""
# self.warns_unchanged(s, "Python 3 does not support string exceptions")
-#
+#
# def test_warn_2(self):
# s = """g.throw("foo", 5)"""
# self.warns_unchanged(s, "Python 3 does not support string exceptions")
-#
+#
# def test_warn_3(self):
# s = """g.throw("foo", 5, 6)"""
# self.warns_unchanged(s, "Python 3 does not support string exceptions")
-#
+#
# # These should not be touched
-#
+#
# def test_untouched_1(self):
# s = """g.throw(Exception)"""
# self.unchanged(s)
-#
+#
# def test_untouched_2(self):
# s = """g.throw(Exception(5, 6))"""
# self.unchanged(s)
-#
+#
# def test_untouched_3(self):
# s = """5 + g.throw(Exception(5, 6))"""
# self.unchanged(s)
-#
+#
# # These should result in traceback-assignment
-#
+#
# def test_tb_1(self):
# b = """def foo():
# g.throw(Exception, 5, 6)"""
# a = """def foo():
# g.throw(Exception(5).with_traceback(6))"""
# self.check(b, a)
-#
+#
# def test_tb_2(self):
# b = """def foo():
# a = 5
@@ -900,14 +952,14 @@ def test_with_future_print_function(self):
# g.throw(Exception(5).with_traceback(6))
# b = 6"""
# self.check(b, a)
-#
+#
# def test_tb_3(self):
# b = """def foo():
# g.throw(Exception,5,6)"""
# a = """def foo():
# g.throw(Exception(5).with_traceback(6))"""
# self.check(b, a)
-#
+#
# def test_tb_4(self):
# b = """def foo():
# a = 5
@@ -918,14 +970,14 @@ def test_with_future_print_function(self):
# g.throw(Exception(5).with_traceback(6))
# b = 6"""
# self.check(b, a)
-#
+#
# def test_tb_5(self):
# b = """def foo():
# g.throw(Exception, (5, 6, 7), 6)"""
# a = """def foo():
# g.throw(Exception(5, 6, 7).with_traceback(6))"""
# self.check(b, a)
-#
+#
# def test_tb_6(self):
# b = """def foo():
# a = 5
@@ -936,14 +988,14 @@ def test_with_future_print_function(self):
# g.throw(Exception(5, 6, 7).with_traceback(6))
# b = 6"""
# self.check(b, a)
-#
+#
# def test_tb_7(self):
# b = """def foo():
# a + g.throw(Exception, 5, 6)"""
# a = """def foo():
# a + g.throw(Exception(5).with_traceback(6))"""
# self.check(b, a)
-#
+#
# def test_tb_8(self):
# b = """def foo():
# a = 5
@@ -954,596 +1006,596 @@ def test_with_future_print_function(self):
# a + g.throw(Exception(5).with_traceback(6))
# b = 6"""
# self.check(b, a)
-#
+#
# class Test_long(FixerTestCase):
# fixer = "long"
-#
+#
# def test_1(self):
# b = """x = long(x)"""
# a = """x = int(x)"""
# self.check(b, a)
-#
+#
# def test_2(self):
# b = """y = isinstance(x, long)"""
# a = """y = isinstance(x, int)"""
# self.check(b, a)
-#
+#
# def test_3(self):
# b = """z = type(x) in (int, long)"""
# a = """z = type(x) in (int, int)"""
# self.check(b, a)
-#
+#
# def test_unchanged(self):
# s = """long = True"""
# self.unchanged(s)
-#
+#
# s = """s.long = True"""
# self.unchanged(s)
-#
+#
# s = """def long(): pass"""
# self.unchanged(s)
-#
+#
# s = """class long(): pass"""
# self.unchanged(s)
-#
+#
# s = """def f(long): pass"""
# self.unchanged(s)
-#
+#
# s = """def f(g, long): pass"""
# self.unchanged(s)
-#
+#
# s = """def f(x, long=True): pass"""
# self.unchanged(s)
-#
+#
# def test_prefix_preservation(self):
# b = """x = long( x )"""
# a = """x = int( x )"""
# self.check(b, a)
-#
-#
+#
+#
# class Test_execfile(FixerTestCase):
# fixer = "execfile"
-#
+#
# def test_conversion(self):
# b = """execfile("fn")"""
# a = """exec(compile(open("fn").read(), "fn", 'exec'))"""
# self.check(b, a)
-#
+#
# b = """execfile("fn", glob)"""
# a = """exec(compile(open("fn").read(), "fn", 'exec'), glob)"""
# self.check(b, a)
-#
+#
# b = """execfile("fn", glob, loc)"""
# a = """exec(compile(open("fn").read(), "fn", 'exec'), glob, loc)"""
# self.check(b, a)
-#
+#
# b = """execfile("fn", globals=glob)"""
# a = """exec(compile(open("fn").read(), "fn", 'exec'), globals=glob)"""
# self.check(b, a)
-#
+#
# b = """execfile("fn", locals=loc)"""
# a = """exec(compile(open("fn").read(), "fn", 'exec'), locals=loc)"""
# self.check(b, a)
-#
+#
# b = """execfile("fn", globals=glob, locals=loc)"""
# a = """exec(compile(open("fn").read(), "fn", 'exec'), globals=glob, locals=loc)"""
# self.check(b, a)
-#
+#
# def test_spacing(self):
# b = """execfile( "fn" )"""
# a = """exec(compile(open( "fn" ).read(), "fn", 'exec'))"""
# self.check(b, a)
-#
+#
# b = """execfile("fn", globals = glob)"""
# a = """exec(compile(open("fn").read(), "fn", 'exec'), globals = glob)"""
# self.check(b, a)
-#
-#
+#
+#
# class Test_isinstance(FixerTestCase):
# fixer = "isinstance"
-#
+#
# def test_remove_multiple_items(self):
# b = """isinstance(x, (int, int, int))"""
# a = """isinstance(x, int)"""
# self.check(b, a)
-#
+#
# b = """isinstance(x, (int, float, int, int, float))"""
# a = """isinstance(x, (int, float))"""
# self.check(b, a)
-#
+#
# b = """isinstance(x, (int, float, int, int, float, str))"""
# a = """isinstance(x, (int, float, str))"""
# self.check(b, a)
-#
+#
# b = """isinstance(foo() + bar(), (x(), y(), x(), int, int))"""
# a = """isinstance(foo() + bar(), (x(), y(), x(), int))"""
# self.check(b, a)
-#
+#
# def test_prefix_preservation(self):
# b = """if isinstance( foo(), ( bar, bar, baz )) : pass"""
# a = """if isinstance( foo(), ( bar, baz )) : pass"""
# self.check(b, a)
-#
+#
# def test_unchanged(self):
# self.unchanged("isinstance(x, (str, int))")
-#
+#
# class Test_dict(FixerTestCase):
# fixer = "dict"
-#
+#
# def test_prefix_preservation(self):
# b = "if d. keys ( ) : pass"
# a = "if list(d. keys ( )) : pass"
# self.check(b, a)
-#
+#
# b = "if d. items ( ) : pass"
# a = "if list(d. items ( )) : pass"
# self.check(b, a)
-#
+#
# b = "if d. iterkeys ( ) : pass"
# a = "if iter(d. keys ( )) : pass"
# self.check(b, a)
-#
+#
# b = "[i for i in d. iterkeys( ) ]"
# a = "[i for i in d. keys( ) ]"
# self.check(b, a)
-#
+#
# b = "if d. viewkeys ( ) : pass"
# a = "if d. keys ( ) : pass"
# self.check(b, a)
-#
+#
# b = "[i for i in d. viewkeys( ) ]"
# a = "[i for i in d. keys( ) ]"
# self.check(b, a)
-#
+#
# def test_trailing_comment(self):
# b = "d.keys() # foo"
# a = "list(d.keys()) # foo"
# self.check(b, a)
-#
+#
# b = "d.items() # foo"
# a = "list(d.items()) # foo"
# self.check(b, a)
-#
+#
# b = "d.iterkeys() # foo"
# a = "iter(d.keys()) # foo"
# self.check(b, a)
-#
+#
# b = """[i for i in d.iterkeys() # foo
# ]"""
# a = """[i for i in d.keys() # foo
# ]"""
# self.check(b, a)
-#
+#
# b = """[i for i in d.iterkeys() # foo
# ]"""
# a = """[i for i in d.keys() # foo
# ]"""
# self.check(b, a)
-#
+#
# b = "d.viewitems() # foo"
# a = "d.items() # foo"
# self.check(b, a)
-#
+#
# def test_unchanged(self):
# for wrapper in fixer_util.consuming_calls:
# s = "s = %s(d.keys())" % wrapper
# self.unchanged(s)
-#
+#
# s = "s = %s(d.values())" % wrapper
# self.unchanged(s)
-#
+#
# s = "s = %s(d.items())" % wrapper
# self.unchanged(s)
-#
+#
# def test_01(self):
# b = "d.keys()"
# a = "list(d.keys())"
# self.check(b, a)
-#
+#
# b = "a[0].foo().keys()"
# a = "list(a[0].foo().keys())"
# self.check(b, a)
-#
+#
# def test_02(self):
# b = "d.items()"
# a = "list(d.items())"
# self.check(b, a)
-#
+#
# def test_03(self):
# b = "d.values()"
# a = "list(d.values())"
# self.check(b, a)
-#
+#
# def test_04(self):
# b = "d.iterkeys()"
# a = "iter(d.keys())"
# self.check(b, a)
-#
+#
# def test_05(self):
# b = "d.iteritems()"
# a = "iter(d.items())"
# self.check(b, a)
-#
+#
# def test_06(self):
# b = "d.itervalues()"
# a = "iter(d.values())"
# self.check(b, a)
-#
+#
# def test_07(self):
# s = "list(d.keys())"
# self.unchanged(s)
-#
+#
# def test_08(self):
# s = "sorted(d.keys())"
# self.unchanged(s)
-#
+#
# def test_09(self):
# b = "iter(d.keys())"
# a = "iter(list(d.keys()))"
# self.check(b, a)
-#
+#
# def test_10(self):
# b = "foo(d.keys())"
# a = "foo(list(d.keys()))"
# self.check(b, a)
-#
+#
# def test_11(self):
# b = "for i in d.keys(): print i"
# a = "for i in list(d.keys()): print i"
# self.check(b, a)
-#
+#
# def test_12(self):
# b = "for i in d.iterkeys(): print i"
# a = "for i in d.keys(): print i"
# self.check(b, a)
-#
+#
# def test_13(self):
# b = "[i for i in d.keys()]"
# a = "[i for i in list(d.keys())]"
# self.check(b, a)
-#
+#
# def test_14(self):
# b = "[i for i in d.iterkeys()]"
# a = "[i for i in d.keys()]"
# self.check(b, a)
-#
+#
# def test_15(self):
# b = "(i for i in d.keys())"
# a = "(i for i in list(d.keys()))"
# self.check(b, a)
-#
+#
# def test_16(self):
# b = "(i for i in d.iterkeys())"
# a = "(i for i in d.keys())"
# self.check(b, a)
-#
+#
# def test_17(self):
# b = "iter(d.iterkeys())"
# a = "iter(d.keys())"
# self.check(b, a)
-#
+#
# def test_18(self):
# b = "list(d.iterkeys())"
# a = "list(d.keys())"
# self.check(b, a)
-#
+#
# def test_19(self):
# b = "sorted(d.iterkeys())"
# a = "sorted(d.keys())"
# self.check(b, a)
-#
+#
# def test_20(self):
# b = "foo(d.iterkeys())"
# a = "foo(iter(d.keys()))"
# self.check(b, a)
-#
+#
# def test_21(self):
# b = "print h.iterkeys().next()"
# a = "print iter(h.keys()).next()"
# self.check(b, a)
-#
+#
# def test_22(self):
# b = "print h.keys()[0]"
# a = "print list(h.keys())[0]"
# self.check(b, a)
-#
+#
# def test_23(self):
# b = "print list(h.iterkeys().next())"
# a = "print list(iter(h.keys()).next())"
# self.check(b, a)
-#
+#
# def test_24(self):
# b = "for x in h.keys()[0]: print x"
# a = "for x in list(h.keys())[0]: print x"
# self.check(b, a)
-#
+#
# def test_25(self):
# b = "d.viewkeys()"
# a = "d.keys()"
# self.check(b, a)
-#
+#
# def test_26(self):
# b = "d.viewitems()"
# a = "d.items()"
# self.check(b, a)
-#
+#
# def test_27(self):
# b = "d.viewvalues()"
# a = "d.values()"
# self.check(b, a)
-#
+#
# def test_14(self):
# b = "[i for i in d.viewkeys()]"
# a = "[i for i in d.keys()]"
# self.check(b, a)
-#
+#
# def test_15(self):
# b = "(i for i in d.viewkeys())"
# a = "(i for i in d.keys())"
# self.check(b, a)
-#
+#
# def test_17(self):
# b = "iter(d.viewkeys())"
# a = "iter(d.keys())"
# self.check(b, a)
-#
+#
# def test_18(self):
# b = "list(d.viewkeys())"
# a = "list(d.keys())"
# self.check(b, a)
-#
+#
# def test_19(self):
# b = "sorted(d.viewkeys())"
# a = "sorted(d.keys())"
# self.check(b, a)
-#
+#
# class Test_xrange(FixerTestCase):
# fixer = "xrange"
-#
+#
# def test_prefix_preservation(self):
# b = """x = xrange( 10 )"""
# a = """x = range( 10 )"""
# self.check(b, a)
-#
+#
# b = """x = xrange( 1 , 10 )"""
# a = """x = range( 1 , 10 )"""
# self.check(b, a)
-#
+#
# b = """x = xrange( 0 , 10 , 2 )"""
# a = """x = range( 0 , 10 , 2 )"""
# self.check(b, a)
-#
+#
# def test_single_arg(self):
# b = """x = xrange(10)"""
# a = """x = range(10)"""
# self.check(b, a)
-#
+#
# def test_two_args(self):
# b = """x = xrange(1, 10)"""
# a = """x = range(1, 10)"""
# self.check(b, a)
-#
+#
# def test_three_args(self):
# b = """x = xrange(0, 10, 2)"""
# a = """x = range(0, 10, 2)"""
# self.check(b, a)
-#
+#
# def test_wrap_in_list(self):
# b = """x = range(10, 3, 9)"""
# a = """x = list(range(10, 3, 9))"""
# self.check(b, a)
-#
+#
# b = """x = foo(range(10, 3, 9))"""
# a = """x = foo(list(range(10, 3, 9)))"""
# self.check(b, a)
-#
+#
# b = """x = range(10, 3, 9) + [4]"""
# a = """x = list(range(10, 3, 9)) + [4]"""
# self.check(b, a)
-#
+#
# b = """x = range(10)[::-1]"""
# a = """x = list(range(10))[::-1]"""
# self.check(b, a)
-#
+#
# b = """x = range(10) [3]"""
# a = """x = list(range(10)) [3]"""
# self.check(b, a)
-#
+#
# def test_xrange_in_for(self):
# b = """for i in xrange(10):\n j=i"""
# a = """for i in range(10):\n j=i"""
# self.check(b, a)
-#
+#
# b = """[i for i in xrange(10)]"""
# a = """[i for i in range(10)]"""
# self.check(b, a)
-#
+#
# def test_range_in_for(self):
# self.unchanged("for i in range(10): pass")
# self.unchanged("[i for i in range(10)]")
-#
+#
# def test_in_contains_test(self):
# self.unchanged("x in range(10, 3, 9)")
-#
+#
# def test_in_consuming_context(self):
# for call in fixer_util.consuming_calls:
# self.unchanged("a = %s(range(10))" % call)
-#
+#
# class Test_xrange_with_reduce(FixerTestCase):
-#
+#
# def setUp(self):
# super(Test_xrange_with_reduce, self).setUp(["xrange", "reduce"])
-#
+#
# def test_double_transform(self):
# b = """reduce(x, xrange(5))"""
# a = """from functools import reduce
# reduce(x, range(5))"""
# self.check(b, a)
-#
+#
# class Test_raw_input(FixerTestCase):
# fixer = "raw_input"
-#
+#
# def test_prefix_preservation(self):
# b = """x = raw_input( )"""
# a = """x = input( )"""
# self.check(b, a)
-#
+#
# b = """x = raw_input( '' )"""
# a = """x = input( '' )"""
# self.check(b, a)
-#
+#
# def test_1(self):
# b = """x = raw_input()"""
# a = """x = input()"""
# self.check(b, a)
-#
+#
# def test_2(self):
# b = """x = raw_input('')"""
# a = """x = input('')"""
# self.check(b, a)
-#
+#
# def test_3(self):
# b = """x = raw_input('prompt')"""
# a = """x = input('prompt')"""
# self.check(b, a)
-#
+#
# def test_4(self):
# b = """x = raw_input(foo(a) + 6)"""
# a = """x = input(foo(a) + 6)"""
# self.check(b, a)
-#
+#
# def test_5(self):
# b = """x = raw_input(invite).split()"""
# a = """x = input(invite).split()"""
# self.check(b, a)
-#
+#
# def test_6(self):
# b = """x = raw_input(invite) . split ()"""
# a = """x = input(invite) . split ()"""
# self.check(b, a)
-#
+#
# def test_8(self):
# b = "x = int(raw_input())"
# a = "x = int(input())"
# self.check(b, a)
-#
+#
# class Test_funcattrs(FixerTestCase):
# fixer = "funcattrs"
-#
+#
# attrs = ["closure", "doc", "name", "defaults", "code", "globals", "dict"]
-#
+#
# def test(self):
# for attr in self.attrs:
# b = "a.func_%s" % attr
# a = "a.__%s__" % attr
# self.check(b, a)
-#
+#
# b = "self.foo.func_%s.foo_bar" % attr
# a = "self.foo.__%s__.foo_bar" % attr
# self.check(b, a)
-#
+#
# def test_unchanged(self):
# for attr in self.attrs:
# s = "foo(func_%s + 5)" % attr
# self.unchanged(s)
-#
+#
# s = "f(foo.__%s__)" % attr
# self.unchanged(s)
-#
+#
# s = "f(foo.__%s__.foo)" % attr
# self.unchanged(s)
-#
+#
# class Test_xreadlines(FixerTestCase):
# fixer = "xreadlines"
-#
+#
# def test_call(self):
# b = "for x in f.xreadlines(): pass"
# a = "for x in f: pass"
# self.check(b, a)
-#
+#
# b = "for x in foo().xreadlines(): pass"
# a = "for x in foo(): pass"
# self.check(b, a)
-#
+#
# b = "for x in (5 + foo()).xreadlines(): pass"
# a = "for x in (5 + foo()): pass"
# self.check(b, a)
-#
+#
# def test_attr_ref(self):
# b = "foo(f.xreadlines + 5)"
# a = "foo(f.__iter__ + 5)"
# self.check(b, a)
-#
+#
# b = "foo(f().xreadlines + 5)"
# a = "foo(f().__iter__ + 5)"
# self.check(b, a)
-#
+#
# b = "foo((5 + f()).xreadlines + 5)"
# a = "foo((5 + f()).__iter__ + 5)"
# self.check(b, a)
-#
+#
# def test_unchanged(self):
# s = "for x in f.xreadlines(5): pass"
# self.unchanged(s)
-#
+#
# s = "for x in f.xreadlines(k=5): pass"
# self.unchanged(s)
-#
+#
# s = "for x in f.xreadlines(*k, **v): pass"
# self.unchanged(s)
-#
+#
# s = "foo(xreadlines)"
# self.unchanged(s)
-#
-#
+#
+#
# class ImportsFixerTests:
-#
+#
# def test_import_module(self):
# for old, new in self.modules.items():
# b = "import %s" % old
# a = "import %s" % new
# self.check(b, a)
-#
+#
# b = "import foo, %s, bar" % old
# a = "import foo, %s, bar" % new
# self.check(b, a)
-#
+#
# def test_import_from(self):
# for old, new in self.modules.items():
# b = "from %s import foo" % old
# a = "from %s import foo" % new
# self.check(b, a)
-#
+#
# b = "from %s import foo, bar" % old
# a = "from %s import foo, bar" % new
# self.check(b, a)
-#
+#
# b = "from %s import (yes, no)" % old
# a = "from %s import (yes, no)" % new
# self.check(b, a)
-#
+#
# def test_import_module_as(self):
# for old, new in self.modules.items():
# b = "import %s as foo_bar" % old
# a = "import %s as foo_bar" % new
# self.check(b, a)
-#
+#
# b = "import %s as foo_bar" % old
# a = "import %s as foo_bar" % new
# self.check(b, a)
-#
+#
# def test_import_from_as(self):
# for old, new in self.modules.items():
# b = "from %s import foo as bar" % old
# a = "from %s import foo as bar" % new
# self.check(b, a)
-#
+#
# def test_star(self):
# for old, new in self.modules.items():
# b = "from %s import *" % old
# a = "from %s import *" % new
# self.check(b, a)
-#
+#
# def test_import_module_usage(self):
# for old, new in self.modules.items():
# b = """
@@ -1555,7 +1607,7 @@ def test_with_future_print_function(self):
# foo(%s.bar)
# """ % (new, new)
# self.check(b, a)
-#
+#
# b = """
# from %s import x
# %s = 23
@@ -1565,13 +1617,13 @@ def test_with_future_print_function(self):
# %s = 23
# """ % (new, old)
# self.check(b, a)
-#
+#
# s = """
# def f():
# %s.method()
# """ % (old,)
# self.unchanged(s)
-#
+#
# # test nested usage
# b = """
# import %s
@@ -1582,7 +1634,7 @@ def test_with_future_print_function(self):
# %s.bar(%s.foo)
# """ % (new, new, new)
# self.check(b, a)
-#
+#
# b = """
# import %s
# x.%s
@@ -1592,16 +1644,16 @@ def test_with_future_print_function(self):
# x.%s
# """ % (new, old)
# self.check(b, a)
-#
-#
+#
+#
# class Test_imports(FixerTestCase, ImportsFixerTests):
# fixer = "imports"
-#
+#
# def test_multiple_imports(self):
# b = """import urlparse, cStringIO"""
# a = """import urllib.parse, io"""
# self.check(b, a)
-#
+#
# def test_multiple_imports_as(self):
# b = """
# import copy_reg as bar, HTMLParser as foo, urlparse
@@ -1612,14 +1664,14 @@ def test_with_future_print_function(self):
# s = urllib.parse.spam(bar.foo())
# """
# self.check(b, a)
-#
-#
+#
+#
# class Test_imports2(FixerTestCase, ImportsFixerTests):
# fixer = "imports2"
-#
-#
+#
+#
# class Test_imports_fixer_order(FixerTestCase, ImportsFixerTests):
-#
+#
# def setUp(self):
# super(Test_imports_fixer_order, self).setUp(['imports', 'imports2'])
# from ..fixes.fix_imports2 import MAPPING as mapping2
@@ -1627,23 +1679,23 @@ def test_with_future_print_function(self):
# from ..fixes.fix_imports import MAPPING as mapping1
# for key in ('dbhash', 'dumbdbm', 'dbm', 'gdbm'):
# self.modules[key] = mapping1[key]
-#
+#
# def test_after_local_imports_refactoring(self):
# for fix in ("imports", "imports2"):
# self.fixer = fix
# self.assert_runs_after("import")
-#
-#
+#
+#
# class Test_urllib(FixerTestCase):
# fixer = "urllib"
# from ..fixes.fix_urllib import MAPPING as modules
-#
+#
# def test_import_module(self):
# for old, changes in self.modules.items():
# b = "import %s" % old
# a = "import %s" % ", ".join(map(itemgetter(0), changes))
# self.check(b, a)
-#
+#
# def test_import_from(self):
# for old, changes in self.modules.items():
# all_members = []
@@ -1653,28 +1705,28 @@ def test_with_future_print_function(self):
# b = "from %s import %s" % (old, member)
# a = "from %s import %s" % (new, member)
# self.check(b, a)
-#
+#
# s = "from foo import %s" % member
# self.unchanged(s)
-#
+#
# b = "from %s import %s" % (old, ", ".join(members))
# a = "from %s import %s" % (new, ", ".join(members))
# self.check(b, a)
-#
+#
# s = "from foo import %s" % ", ".join(members)
# self.unchanged(s)
-#
+#
# # test the breaking of a module into multiple replacements
# b = "from %s import %s" % (old, ", ".join(all_members))
# a = "\n".join(["from %s import %s" % (new, ", ".join(members))
# for (new, members) in changes])
# self.check(b, a)
-#
+#
# def test_import_module_as(self):
# for old in self.modules:
# s = "import %s as foo" % old
# self.warns_unchanged(s, "This module is now multiple modules")
-#
+#
# def test_import_from_as(self):
# for old, changes in self.modules.items():
# for new, members in changes:
@@ -1685,12 +1737,12 @@ def test_with_future_print_function(self):
# b = "from %s import %s as blah, %s" % (old, member, member)
# a = "from %s import %s as blah, %s" % (new, member, member)
# self.check(b, a)
-#
+#
# def test_star(self):
# for old in self.modules:
# s = "from %s import *" % old
# self.warns_unchanged(s, "Cannot handle star imports")
-#
+#
# def test_indented(self):
# b = """
# def foo():
@@ -1702,7 +1754,7 @@ def test_with_future_print_function(self):
# from urllib.request import urlopen
# """
# self.check(b, a)
-#
+#
# b = """
# def foo():
# other()
@@ -1715,9 +1767,9 @@ def test_with_future_print_function(self):
# from urllib.request import urlopen
# """
# self.check(b, a)
-#
-#
-#
+#
+#
+#
# def test_import_module_usage(self):
# for old, changes in self.modules.items():
# for new, members in changes:
@@ -1742,163 +1794,163 @@ def test_with_future_print_function(self):
# %s.%s(%s.%s)
# """ % (new_import, new, member, new, member)
# self.check(b, a)
-#
-#
+#
+#
# class Test_input(FixerTestCase):
# fixer = "input"
-#
+#
# def test_prefix_preservation(self):
# b = """x = input( )"""
# a = """x = eval(input( ))"""
# self.check(b, a)
-#
+#
# b = """x = input( '' )"""
# a = """x = eval(input( '' ))"""
# self.check(b, a)
-#
+#
# def test_trailing_comment(self):
# b = """x = input() # foo"""
# a = """x = eval(input()) # foo"""
# self.check(b, a)
-#
+#
# def test_idempotency(self):
# s = """x = eval(input())"""
# self.unchanged(s)
-#
+#
# s = """x = eval(input(''))"""
# self.unchanged(s)
-#
+#
# s = """x = eval(input(foo(5) + 9))"""
# self.unchanged(s)
-#
+#
# def test_1(self):
# b = """x = input()"""
# a = """x = eval(input())"""
# self.check(b, a)
-#
+#
# def test_2(self):
# b = """x = input('')"""
# a = """x = eval(input(''))"""
# self.check(b, a)
-#
+#
# def test_3(self):
# b = """x = input('prompt')"""
# a = """x = eval(input('prompt'))"""
# self.check(b, a)
-#
+#
# def test_4(self):
# b = """x = input(foo(5) + 9)"""
# a = """x = eval(input(foo(5) + 9))"""
# self.check(b, a)
-#
+#
# class Test_tuple_params(FixerTestCase):
# fixer = "tuple_params"
-#
+#
# def test_unchanged_1(self):
# s = """def foo(): pass"""
# self.unchanged(s)
-#
+#
# def test_unchanged_2(self):
# s = """def foo(a, b, c): pass"""
# self.unchanged(s)
-#
+#
# def test_unchanged_3(self):
# s = """def foo(a=3, b=4, c=5): pass"""
# self.unchanged(s)
-#
+#
# def test_1(self):
# b = """
# def foo(((a, b), c)):
# x = 5"""
-#
+#
# a = """
# def foo(xxx_todo_changeme):
# ((a, b), c) = xxx_todo_changeme
# x = 5"""
# self.check(b, a)
-#
+#
# def test_2(self):
# b = """
# def foo(((a, b), c), d):
# x = 5"""
-#
+#
# a = """
# def foo(xxx_todo_changeme, d):
# ((a, b), c) = xxx_todo_changeme
# x = 5"""
# self.check(b, a)
-#
+#
# def test_3(self):
# b = """
# def foo(((a, b), c), d) -> e:
# x = 5"""
-#
+#
# a = """
# def foo(xxx_todo_changeme, d) -> e:
# ((a, b), c) = xxx_todo_changeme
# x = 5"""
# self.check(b, a)
-#
+#
# def test_semicolon(self):
# b = """
# def foo(((a, b), c)): x = 5; y = 7"""
-#
+#
# a = """
# def foo(xxx_todo_changeme): ((a, b), c) = xxx_todo_changeme; x = 5; y = 7"""
# self.check(b, a)
-#
+#
# def test_keywords(self):
# b = """
# def foo(((a, b), c), d, e=5) -> z:
# x = 5"""
-#
+#
# a = """
# def foo(xxx_todo_changeme, d, e=5) -> z:
# ((a, b), c) = xxx_todo_changeme
# x = 5"""
# self.check(b, a)
-#
+#
# def test_varargs(self):
# b = """
# def foo(((a, b), c), d, *vargs, **kwargs) -> z:
# x = 5"""
-#
+#
# a = """
# def foo(xxx_todo_changeme, d, *vargs, **kwargs) -> z:
# ((a, b), c) = xxx_todo_changeme
# x = 5"""
# self.check(b, a)
-#
+#
# def test_multi_1(self):
# b = """
# def foo(((a, b), c), (d, e, f)) -> z:
# x = 5"""
-#
+#
# a = """
# def foo(xxx_todo_changeme, xxx_todo_changeme1) -> z:
# ((a, b), c) = xxx_todo_changeme
# (d, e, f) = xxx_todo_changeme1
# x = 5"""
# self.check(b, a)
-#
+#
# def test_multi_2(self):
# b = """
# def foo(x, ((a, b), c), d, (e, f, g), y) -> z:
# x = 5"""
-#
+#
# a = """
# def foo(x, xxx_todo_changeme, d, xxx_todo_changeme1, y) -> z:
# ((a, b), c) = xxx_todo_changeme
# (e, f, g) = xxx_todo_changeme1
# x = 5"""
# self.check(b, a)
-#
+#
# def test_docstring(self):
# b = """
# def foo(((a, b), c), (d, e, f)) -> z:
# "foo foo foo foo"
# x = 5"""
-#
+#
# a = """
# def foo(xxx_todo_changeme, xxx_todo_changeme1) -> z:
# "foo foo foo foo"
@@ -1906,83 +1958,83 @@ def test_with_future_print_function(self):
# (d, e, f) = xxx_todo_changeme1
# x = 5"""
# self.check(b, a)
-#
+#
# def test_lambda_no_change(self):
# s = """lambda x: x + 5"""
# self.unchanged(s)
-#
+#
# def test_lambda_parens_single_arg(self):
# b = """lambda (x): x + 5"""
# a = """lambda x: x + 5"""
# self.check(b, a)
-#
+#
# b = """lambda(x): x + 5"""
# a = """lambda x: x + 5"""
# self.check(b, a)
-#
+#
# b = """lambda ((((x)))): x + 5"""
# a = """lambda x: x + 5"""
# self.check(b, a)
-#
+#
# b = """lambda((((x)))): x + 5"""
# a = """lambda x: x + 5"""
# self.check(b, a)
-#
+#
# def test_lambda_simple(self):
# b = """lambda (x, y): x + f(y)"""
# a = """lambda x_y: x_y[0] + f(x_y[1])"""
# self.check(b, a)
-#
+#
# b = """lambda(x, y): x + f(y)"""
# a = """lambda x_y: x_y[0] + f(x_y[1])"""
# self.check(b, a)
-#
+#
# b = """lambda (((x, y))): x + f(y)"""
# a = """lambda x_y: x_y[0] + f(x_y[1])"""
# self.check(b, a)
-#
+#
# b = """lambda(((x, y))): x + f(y)"""
# a = """lambda x_y: x_y[0] + f(x_y[1])"""
# self.check(b, a)
-#
+#
# def test_lambda_one_tuple(self):
# b = """lambda (x,): x + f(x)"""
# a = """lambda x1: x1[0] + f(x1[0])"""
# self.check(b, a)
-#
+#
# b = """lambda (((x,))): x + f(x)"""
# a = """lambda x1: x1[0] + f(x1[0])"""
# self.check(b, a)
-#
+#
# def test_lambda_simple_multi_use(self):
# b = """lambda (x, y): x + x + f(x) + x"""
# a = """lambda x_y: x_y[0] + x_y[0] + f(x_y[0]) + x_y[0]"""
# self.check(b, a)
-#
+#
# def test_lambda_simple_reverse(self):
# b = """lambda (x, y): y + x"""
# a = """lambda x_y: x_y[1] + x_y[0]"""
# self.check(b, a)
-#
+#
# def test_lambda_nested(self):
# b = """lambda (x, (y, z)): x + y + z"""
# a = """lambda x_y_z: x_y_z[0] + x_y_z[1][0] + x_y_z[1][1]"""
# self.check(b, a)
-#
+#
# b = """lambda (((x, (y, z)))): x + y + z"""
# a = """lambda x_y_z: x_y_z[0] + x_y_z[1][0] + x_y_z[1][1]"""
# self.check(b, a)
-#
+#
# def test_lambda_nested_multi_use(self):
# b = """lambda (x, (y, z)): x + y + f(y)"""
# a = """lambda x_y_z: x_y_z[0] + x_y_z[1][0] + f(x_y_z[1][0])"""
# self.check(b, a)
-#
+#
# class Test_methodattrs(FixerTestCase):
# fixer = "methodattrs"
-#
+#
# attrs = ["func", "self", "class"]
-#
+#
# def test(self):
# for attr in self.attrs:
# b = "a.im_%s" % attr
@@ -1991,58 +2043,58 @@ def test_with_future_print_function(self):
# else:
# a = "a.__%s__" % attr
# self.check(b, a)
-#
+#
# b = "self.foo.im_%s.foo_bar" % attr
# if attr == "class":
# a = "self.foo.__self__.__class__.foo_bar"
# else:
# a = "self.foo.__%s__.foo_bar" % attr
# self.check(b, a)
-#
+#
# def test_unchanged(self):
# for attr in self.attrs:
# s = "foo(im_%s + 5)" % attr
# self.unchanged(s)
-#
+#
# s = "f(foo.__%s__)" % attr
# self.unchanged(s)
-#
+#
# s = "f(foo.__%s__.foo)" % attr
# self.unchanged(s)
-#
+#
# class Test_next(FixerTestCase):
# fixer = "next"
-#
+#
# def test_1(self):
# b = """it.next()"""
# a = """next(it)"""
# self.check(b, a)
-#
+#
# def test_2(self):
# b = """a.b.c.d.next()"""
# a = """next(a.b.c.d)"""
# self.check(b, a)
-#
+#
# def test_3(self):
# b = """(a + b).next()"""
# a = """next((a + b))"""
# self.check(b, a)
-#
+#
# def test_4(self):
# b = """a().next()"""
# a = """next(a())"""
# self.check(b, a)
-#
+#
# def test_5(self):
# b = """a().next() + b"""
# a = """next(a()) + b"""
# self.check(b, a)
-#
+#
# def test_6(self):
# b = """c( a().next() + b)"""
# a = """c( next(a()) + b)"""
# self.check(b, a)
-#
+#
# def test_prefix_preservation_1(self):
# b = """
# for a in b:
@@ -2055,7 +2107,7 @@ def test_with_future_print_function(self):
# next(a)
# """
# self.check(b, a)
-#
+#
# def test_prefix_preservation_2(self):
# b = """
# for a in b:
@@ -2070,7 +2122,7 @@ def test_with_future_print_function(self):
# next(a)
# """
# self.check(b, a)
-#
+#
# def test_prefix_preservation_3(self):
# b = """
# next = 5
@@ -2085,7 +2137,7 @@ def test_with_future_print_function(self):
# a.__next__()
# """
# self.check(b, a, ignore_warnings=True)
-#
+#
# def test_prefix_preservation_4(self):
# b = """
# next = 5
@@ -2102,7 +2154,7 @@ def test_with_future_print_function(self):
# a.__next__()
# """
# self.check(b, a, ignore_warnings=True)
-#
+#
# def test_prefix_preservation_5(self):
# b = """
# next = 5
@@ -2117,7 +2169,7 @@ def test_with_future_print_function(self):
# a.__next__())
# """
# self.check(b, a, ignore_warnings=True)
-#
+#
# def test_prefix_preservation_6(self):
# b = """
# for a in b:
@@ -2130,7 +2182,7 @@ def test_with_future_print_function(self):
# next(a))
# """
# self.check(b, a)
-#
+#
# def test_method_1(self):
# b = """
# class A:
@@ -2143,7 +2195,7 @@ def test_with_future_print_function(self):
# pass
# """
# self.check(b, a)
-#
+#
# def test_method_2(self):
# b = """
# class A(object):
@@ -2156,7 +2208,7 @@ def test_with_future_print_function(self):
# pass
# """
# self.check(b, a)
-#
+#
# def test_method_3(self):
# b = """
# class A:
@@ -2169,16 +2221,16 @@ def test_with_future_print_function(self):
# pass
# """
# self.check(b, a)
-#
+#
# def test_method_4(self):
# b = """
# class A:
# def __init__(self, foo):
# self.foo = foo
-#
+#
# def next(self):
# pass
-#
+#
# def __iter__(self):
# return self
# """
@@ -2186,15 +2238,15 @@ def test_with_future_print_function(self):
# class A:
# def __init__(self, foo):
# self.foo = foo
-#
+#
# def __next__(self):
# pass
-#
+#
# def __iter__(self):
# return self
# """
# self.check(b, a)
-#
+#
# def test_method_unchanged(self):
# s = """
# class A:
@@ -2202,227 +2254,227 @@ def test_with_future_print_function(self):
# pass
# """
# self.unchanged(s)
-#
+#
# def test_shadowing_assign_simple(self):
# s = """
# next = foo
-#
+#
# class A:
# def next(self, a, b):
# pass
# """
# self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")
-#
+#
# def test_shadowing_assign_tuple_1(self):
# s = """
# (next, a) = foo
-#
+#
# class A:
# def next(self, a, b):
# pass
# """
# self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")
-#
+#
# def test_shadowing_assign_tuple_2(self):
# s = """
# (a, (b, (next, c)), a) = foo
-#
+#
# class A:
# def next(self, a, b):
# pass
# """
# self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")
-#
+#
# def test_shadowing_assign_list_1(self):
# s = """
# [next, a] = foo
-#
+#
# class A:
# def next(self, a, b):
# pass
# """
# self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")
-#
+#
# def test_shadowing_assign_list_2(self):
# s = """
# [a, [b, [next, c]], a] = foo
-#
+#
# class A:
# def next(self, a, b):
# pass
# """
# self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")
-#
+#
# def test_builtin_assign(self):
# s = """
# def foo():
# __builtin__.next = foo
-#
+#
# class A:
# def next(self, a, b):
# pass
# """
# self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")
-#
+#
# def test_builtin_assign_in_tuple(self):
# s = """
# def foo():
# (a, __builtin__.next) = foo
-#
+#
# class A:
# def next(self, a, b):
# pass
# """
# self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")
-#
+#
# def test_builtin_assign_in_list(self):
# s = """
# def foo():
# [a, __builtin__.next] = foo
-#
+#
# class A:
# def next(self, a, b):
# pass
# """
# self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")
-#
+#
# def test_assign_to_next(self):
# s = """
# def foo():
# A.next = foo
-#
+#
# class A:
# def next(self, a, b):
# pass
# """
# self.unchanged(s)
-#
+#
# def test_assign_to_next_in_tuple(self):
# s = """
# def foo():
# (a, A.next) = foo
-#
+#
# class A:
# def next(self, a, b):
# pass
# """
# self.unchanged(s)
-#
+#
# def test_assign_to_next_in_list(self):
# s = """
# def foo():
# [a, A.next] = foo
-#
+#
# class A:
# def next(self, a, b):
# pass
# """
# self.unchanged(s)
-#
+#
# def test_shadowing_import_1(self):
# s = """
# import foo.bar as next
-#
+#
# class A:
# def next(self, a, b):
# pass
# """
# self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")
-#
+#
# def test_shadowing_import_2(self):
# s = """
# import bar, bar.foo as next
-#
+#
# class A:
# def next(self, a, b):
# pass
# """
# self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")
-#
+#
# def test_shadowing_import_3(self):
# s = """
# import bar, bar.foo as next, baz
-#
+#
# class A:
# def next(self, a, b):
# pass
# """
# self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")
-#
+#
# def test_shadowing_import_from_1(self):
# s = """
# from x import next
-#
+#
# class A:
# def next(self, a, b):
# pass
# """
# self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")
-#
+#
# def test_shadowing_import_from_2(self):
# s = """
# from x.a import next
-#
+#
# class A:
# def next(self, a, b):
# pass
# """
# self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")
-#
+#
# def test_shadowing_import_from_3(self):
# s = """
# from x import a, next, b
-#
+#
# class A:
# def next(self, a, b):
# pass
# """
# self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")
-#
+#
# def test_shadowing_import_from_4(self):
# s = """
# from x.a import a, next, b
-#
+#
# class A:
# def next(self, a, b):
# pass
# """
# self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")
-#
+#
# def test_shadowing_funcdef_1(self):
# s = """
# def next(a):
# pass
-#
+#
# class A:
# def next(self, a, b):
# pass
# """
# self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")
-#
+#
# def test_shadowing_funcdef_2(self):
# b = """
# def next(a):
# pass
-#
+#
# class A:
# def next(self):
# pass
-#
+#
# it.next()
# """
# a = """
# def next(a):
# pass
-#
+#
# class A:
# def __next__(self):
# pass
-#
+#
# it.__next__()
# """
# self.warns(b, a, "Calls to builtin next() possibly shadowed")
-#
+#
# def test_shadowing_global_1(self):
# s = """
# def f():
@@ -2430,7 +2482,7 @@ def test_with_future_print_function(self):
# next = 5
# """
# self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")
-#
+#
# def test_shadowing_global_2(self):
# s = """
# def f():
@@ -2438,55 +2490,55 @@ def test_with_future_print_function(self):
# next = 5
# """
# self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")
-#
+#
# def test_shadowing_for_simple(self):
# s = """
# for next in it():
# pass
-#
+#
# b = 5
# c = 6
# """
# self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")
-#
+#
# def test_shadowing_for_tuple_1(self):
# s = """
# for next, b in it():
# pass
-#
+#
# b = 5
# c = 6
# """
# self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")
-#
+#
# def test_shadowing_for_tuple_2(self):
# s = """
# for a, (next, c), b in it():
# pass
-#
+#
# b = 5
# c = 6
# """
# self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")
-#
+#
# def test_noncall_access_1(self):
# b = """gnext = g.next"""
# a = """gnext = g.__next__"""
# self.check(b, a)
-#
+#
# def test_noncall_access_2(self):
# b = """f(g.next + 5)"""
# a = """f(g.__next__ + 5)"""
# self.check(b, a)
-#
+#
# def test_noncall_access_3(self):
# b = """f(g().next + 5)"""
# a = """f(g().__next__ + 5)"""
# self.check(b, a)
-#
+#
# class Test_nonzero(FixerTestCase):
# fixer = "nonzero"
-#
+#
# def test_1(self):
# b = """
# class A:
@@ -2499,7 +2551,7 @@ def test_with_future_print_function(self):
# pass
# """
# self.check(b, a)
-#
+#
# def test_2(self):
# b = """
# class A(object):
@@ -2512,7 +2564,7 @@ def test_with_future_print_function(self):
# pass
# """
# self.check(b, a)
-#
+#
# def test_unchanged_1(self):
# s = """
# class A(object):
@@ -2520,7 +2572,7 @@ def test_with_future_print_function(self):
# pass
# """
# self.unchanged(s)
-#
+#
# def test_unchanged_2(self):
# s = """
# class A(object):
@@ -2528,101 +2580,101 @@ def test_with_future_print_function(self):
# pass
# """
# self.unchanged(s)
-#
+#
# def test_unchanged_func(self):
# s = """
# def __nonzero__(self):
# pass
# """
# self.unchanged(s)
-#
+#
# class Test_numliterals(FixerTestCase):
# fixer = "numliterals"
-#
+#
# def test_octal_1(self):
# b = """0755"""
# a = """0o755"""
# self.check(b, a)
-#
+#
# def test_long_int_1(self):
# b = """a = 12L"""
# a = """a = 12"""
# self.check(b, a)
-#
+#
# def test_long_int_2(self):
# b = """a = 12l"""
# a = """a = 12"""
# self.check(b, a)
-#
+#
# def test_long_hex(self):
# b = """b = 0x12l"""
# a = """b = 0x12"""
# self.check(b, a)
-#
+#
# def test_comments_and_spacing(self):
# b = """b = 0x12L"""
# a = """b = 0x12"""
# self.check(b, a)
-#
+#
# b = """b = 0755 # spam"""
# a = """b = 0o755 # spam"""
# self.check(b, a)
-#
+#
# def test_unchanged_int(self):
# s = """5"""
# self.unchanged(s)
-#
+#
# def test_unchanged_float(self):
# s = """5.0"""
# self.unchanged(s)
-#
+#
# def test_unchanged_octal(self):
# s = """0o755"""
# self.unchanged(s)
-#
+#
# def test_unchanged_hex(self):
# s = """0xABC"""
# self.unchanged(s)
-#
+#
# def test_unchanged_exp(self):
# s = """5.0e10"""
# self.unchanged(s)
-#
+#
# def test_unchanged_complex_int(self):
# s = """5 + 4j"""
# self.unchanged(s)
-#
+#
# def test_unchanged_complex_float(self):
# s = """5.4 + 4.9j"""
# self.unchanged(s)
-#
+#
# def test_unchanged_complex_bare(self):
# s = """4j"""
# self.unchanged(s)
# s = """4.4j"""
# self.unchanged(s)
-#
+#
# class Test_renames(FixerTestCase):
# fixer = "renames"
-#
+#
# modules = {"sys": ("maxint", "maxsize"),
# }
-#
+#
# def test_import_from(self):
# for mod, (old, new) in self.modules.items():
# b = "from %s import %s" % (mod, old)
# a = "from %s import %s" % (mod, new)
# self.check(b, a)
-#
+#
# s = "from foo import %s" % old
# self.unchanged(s)
-#
+#
# def test_import_from_as(self):
# for mod, (old, new) in self.modules.items():
# b = "from %s import %s as foo_bar" % (mod, old)
# a = "from %s import %s as foo_bar" % (mod, new)
# self.check(b, a)
-#
+#
# def test_import_module_usage(self):
# for mod, (old, new) in self.modules.items():
# b = """
@@ -2634,7 +2686,7 @@ def test_with_future_print_function(self):
# foo(%s, %s.%s)
# """ % (mod, mod, mod, new)
# self.check(b, a)
-#
+#
# def XXX_test_from_import_usage(self):
# # not implemented yet
# for mod, (old, new) in self.modules.items():
@@ -2647,66 +2699,66 @@ def test_with_future_print_function(self):
# foo(%s, %s)
# """ % (mod, new, mod, new)
# self.check(b, a)
-#
+#
# class Test_unicode(FixerTestCase):
# fixer = "unicode"
-#
+#
# def test_whitespace(self):
# b = """unicode( x)"""
# a = """str( x)"""
# self.check(b, a)
-#
+#
# b = """ unicode(x )"""
# a = """ str(x )"""
# self.check(b, a)
-#
+#
# b = """ u'h'"""
# a = """ 'h'"""
# self.check(b, a)
-#
+#
# def test_unicode_call(self):
# b = """unicode(x, y, z)"""
# a = """str(x, y, z)"""
# self.check(b, a)
-#
+#
# def test_unichr(self):
# b = """unichr(u'h')"""
# a = """chr('h')"""
# self.check(b, a)
-#
+#
# def test_unicode_literal_1(self):
# b = '''u"x"'''
# a = '''"x"'''
# self.check(b, a)
-#
+#
# def test_unicode_literal_2(self):
# b = """ur'x'"""
# a = """r'x'"""
# self.check(b, a)
-#
+#
# def test_unicode_literal_3(self):
# b = """UR'''x''' """
# a = """R'''x''' """
# self.check(b, a)
-#
+#
# class Test_callable(FixerTestCase):
# fixer = "callable"
-#
+#
# def test_prefix_preservation(self):
# b = """callable( x)"""
# a = """import collections\nisinstance( x, collections.Callable)"""
# self.check(b, a)
-#
+#
# b = """if callable(x): pass"""
# a = """import collections
# if isinstance(x, collections.Callable): pass"""
# self.check(b, a)
-#
+#
# def test_callable_call(self):
# b = """callable(x)"""
# a = """import collections\nisinstance(x, collections.Callable)"""
# self.check(b, a)
-#
+#
# def test_global_import(self):
# b = """
# def spam(foo):
@@ -2716,14 +2768,14 @@ def test_with_future_print_function(self):
# def spam(foo):
# isinstance(foo, collections.Callable)"""[1:]
# self.check(b, a)
-#
+#
# b = """
# import collections
# def spam(foo):
# callable(foo)"""[1:]
# # same output if it was already imported
# self.check(b, a)
-#
+#
# b = """
# from collections import *
# def spam(foo):
@@ -2734,7 +2786,7 @@ def test_with_future_print_function(self):
# def spam(foo):
# isinstance(foo, collections.Callable)"""[1:]
# self.check(b, a)
-#
+#
# b = """
# do_stuff()
# do_some_other_stuff()
@@ -2745,7 +2797,7 @@ def test_with_future_print_function(self):
# do_some_other_stuff()
# assert isinstance(do_stuff, collections.Callable)"""[1:]
# self.check(b, a)
-#
+#
# b = """
# if isinstance(do_stuff, Callable):
# assert callable(do_stuff)
@@ -2768,55 +2820,55 @@ def test_with_future_print_function(self):
# else:
# assert not isinstance(do_stuff, collections.Callable)"""[1:]
# self.check(b, a)
-#
+#
# def test_callable_should_not_change(self):
# a = """callable(*x)"""
# self.unchanged(a)
-#
+#
# a = """callable(x, y)"""
# self.unchanged(a)
-#
+#
# a = """callable(x, kw=y)"""
# self.unchanged(a)
-#
+#
# a = """callable()"""
# self.unchanged(a)
-#
+#
# class Test_filter(FixerTestCase):
# fixer = "filter"
-#
+#
# def test_prefix_preservation(self):
# b = """x = filter( foo, 'abc' )"""
# a = """x = list(filter( foo, 'abc' ))"""
# self.check(b, a)
-#
+#
# b = """x = filter( None , 'abc' )"""
# a = """x = [_f for _f in 'abc' if _f]"""
# self.check(b, a)
-#
+#
# def test_filter_basic(self):
# b = """x = filter(None, 'abc')"""
# a = """x = [_f for _f in 'abc' if _f]"""
# self.check(b, a)
-#
+#
# b = """x = len(filter(f, 'abc'))"""
# a = """x = len(list(filter(f, 'abc')))"""
# self.check(b, a)
-#
+#
# b = """x = filter(lambda x: x%2 == 0, range(10))"""
# a = """x = [x for x in range(10) if x%2 == 0]"""
# self.check(b, a)
-#
+#
# # Note the parens around x
# b = """x = filter(lambda (x): x%2 == 0, range(10))"""
# a = """x = [x for x in range(10) if x%2 == 0]"""
# self.check(b, a)
-#
+#
# # XXX This (rare) case is not supported
# ## b = """x = filter(f, 'abc')[0]"""
# ## a = """x = list(filter(f, 'abc'))[0]"""
# ## self.check(b, a)
-#
+#
# def test_filter_nochange(self):
# a = """b.join(filter(f, 'abc'))"""
# self.unchanged(a)
@@ -2856,62 +2908,62 @@ def test_with_future_print_function(self):
# self.unchanged(a)
# a = """(x for x in filter(f, 'abc'))"""
# self.unchanged(a)
-#
+#
# def test_future_builtins(self):
# a = "from future_builtins import spam, filter; filter(f, 'ham')"
# self.unchanged(a)
-#
+#
# b = """from future_builtins import spam; x = filter(f, 'abc')"""
# a = """from future_builtins import spam; x = list(filter(f, 'abc'))"""
# self.check(b, a)
-#
+#
# a = "from future_builtins import *; filter(f, 'ham')"
# self.unchanged(a)
-#
+#
# class Test_map(FixerTestCase):
# fixer = "map"
-#
+#
# def check(self, b, a):
# self.unchanged("from future_builtins import map; " + b, a)
# super(Test_map, self).check(b, a)
-#
+#
# def test_prefix_preservation(self):
# b = """x = map( f, 'abc' )"""
# a = """x = list(map( f, 'abc' ))"""
# self.check(b, a)
-#
+#
# def test_trailing_comment(self):
# b = """x = map(f, 'abc') # foo"""
# a = """x = list(map(f, 'abc')) # foo"""
# self.check(b, a)
-#
+#
# def test_None_with_multiple_arguments(self):
# s = """x = map(None, a, b, c)"""
# self.warns_unchanged(s, "cannot convert map(None, ...) with "
# "multiple arguments")
-#
+#
# def test_map_basic(self):
# b = """x = map(f, 'abc')"""
# a = """x = list(map(f, 'abc'))"""
# self.check(b, a)
-#
+#
# b = """x = len(map(f, 'abc', 'def'))"""
# a = """x = len(list(map(f, 'abc', 'def')))"""
# self.check(b, a)
-#
+#
# b = """x = map(None, 'abc')"""
# a = """x = list('abc')"""
# self.check(b, a)
-#
+#
# b = """x = map(lambda x: x+1, range(4))"""
# a = """x = [x+1 for x in range(4)]"""
# self.check(b, a)
-#
+#
# # Note the parens around x
# b = """x = map(lambda (x): x+1, range(4))"""
# a = """x = [x+1 for x in range(4)]"""
# self.check(b, a)
-#
+#
# b = """
# foo()
# # foo
@@ -2923,12 +2975,12 @@ def test_with_future_print_function(self):
# list(map(f, x))
# """
# self.warns(b, a, "You should use a for loop here")
-#
+#
# # XXX This (rare) case is not supported
# ## b = """x = map(f, 'abc')[0]"""
# ## a = """x = list(map(f, 'abc'))[0]"""
# ## self.check(b, a)
-#
+#
# def test_map_nochange(self):
# a = """b.join(map(f, 'abc'))"""
# self.unchanged(a)
@@ -2968,34 +3020,34 @@ def test_with_future_print_function(self):
# self.unchanged(a)
# a = """(x for x in map(f, 'abc'))"""
# self.unchanged(a)
-#
+#
# def test_future_builtins(self):
# a = "from future_builtins import spam, map, eggs; map(f, 'ham')"
# self.unchanged(a)
-#
+#
# b = """from future_builtins import spam, eggs; x = map(f, 'abc')"""
# a = """from future_builtins import spam, eggs; x = list(map(f, 'abc'))"""
# self.check(b, a)
-#
+#
# a = "from future_builtins import *; map(f, 'ham')"
# self.unchanged(a)
-#
+#
# class Test_zip(FixerTestCase):
# fixer = "zip"
-#
+#
# def check(self, b, a):
# self.unchanged("from future_builtins import zip; " + b, a)
# super(Test_zip, self).check(b, a)
-#
+#
# def test_zip_basic(self):
# b = """x = zip(a, b, c)"""
# a = """x = list(zip(a, b, c))"""
# self.check(b, a)
-#
+#
# b = """x = len(zip(a, b))"""
# a = """x = len(list(zip(a, b)))"""
# self.check(b, a)
-#
+#
# def test_zip_nochange(self):
# a = """b.join(zip(a, b))"""
# self.unchanged(a)
@@ -3035,74 +3087,74 @@ def test_with_future_print_function(self):
# self.unchanged(a)
# a = """(x for x in zip(a, b))"""
# self.unchanged(a)
-#
+#
# def test_future_builtins(self):
# a = "from future_builtins import spam, zip, eggs; zip(a, b)"
# self.unchanged(a)
-#
+#
# b = """from future_builtins import spam, eggs; x = zip(a, b)"""
# a = """from future_builtins import spam, eggs; x = list(zip(a, b))"""
# self.check(b, a)
-#
+#
# a = "from future_builtins import *; zip(a, b)"
# self.unchanged(a)
-#
+#
# class Test_standarderror(FixerTestCase):
# fixer = "standarderror"
-#
+#
# def test(self):
# b = """x = StandardError()"""
# a = """x = Exception()"""
# self.check(b, a)
-#
+#
# b = """x = StandardError(a, b, c)"""
# a = """x = Exception(a, b, c)"""
# self.check(b, a)
-#
+#
# b = """f(2 + StandardError(a, b, c))"""
# a = """f(2 + Exception(a, b, c))"""
# self.check(b, a)
-#
+#
# class Test_types(FixerTestCase):
# fixer = "types"
-#
+#
# def test_basic_types_convert(self):
# b = """types.StringType"""
# a = """bytes"""
# self.check(b, a)
-#
+#
# b = """types.DictType"""
# a = """dict"""
# self.check(b, a)
-#
+#
# b = """types . IntType"""
# a = """int"""
# self.check(b, a)
-#
+#
# b = """types.ListType"""
# a = """list"""
# self.check(b, a)
-#
+#
# b = """types.LongType"""
# a = """int"""
# self.check(b, a)
-#
+#
# b = """types.NoneType"""
# a = """type(None)"""
# self.check(b, a)
-#
+#
# class Test_idioms(FixerTestCase):
# fixer = "idioms"
-#
+#
# def test_while(self):
# b = """while 1: foo()"""
# a = """while True: foo()"""
# self.check(b, a)
-#
+#
# b = """while 1: foo()"""
# a = """while True: foo()"""
# self.check(b, a)
-#
+#
# b = """
# while 1:
# foo()
@@ -3112,132 +3164,132 @@ def test_with_future_print_function(self):
# foo()
# """
# self.check(b, a)
-#
+#
# def test_while_unchanged(self):
# s = """while 11: foo()"""
# self.unchanged(s)
-#
+#
# s = """while 0: foo()"""
# self.unchanged(s)
-#
+#
# s = """while foo(): foo()"""
# self.unchanged(s)
-#
+#
# s = """while []: foo()"""
# self.unchanged(s)
-#
+#
# def test_eq_simple(self):
# b = """type(x) == T"""
# a = """isinstance(x, T)"""
# self.check(b, a)
-#
+#
# b = """if type(x) == T: pass"""
# a = """if isinstance(x, T): pass"""
# self.check(b, a)
-#
+#
# def test_eq_reverse(self):
# b = """T == type(x)"""
# a = """isinstance(x, T)"""
# self.check(b, a)
-#
+#
# b = """if T == type(x): pass"""
# a = """if isinstance(x, T): pass"""
# self.check(b, a)
-#
+#
# def test_eq_expression(self):
# b = """type(x+y) == d.get('T')"""
# a = """isinstance(x+y, d.get('T'))"""
# self.check(b, a)
-#
+#
# b = """type( x + y) == d.get('T')"""
# a = """isinstance(x + y, d.get('T'))"""
# self.check(b, a)
-#
+#
# def test_is_simple(self):
# b = """type(x) is T"""
# a = """isinstance(x, T)"""
# self.check(b, a)
-#
+#
# b = """if type(x) is T: pass"""
# a = """if isinstance(x, T): pass"""
# self.check(b, a)
-#
+#
# def test_is_reverse(self):
# b = """T is type(x)"""
# a = """isinstance(x, T)"""
# self.check(b, a)
-#
+#
# b = """if T is type(x): pass"""
# a = """if isinstance(x, T): pass"""
# self.check(b, a)
-#
+#
# def test_is_expression(self):
# b = """type(x+y) is d.get('T')"""
# a = """isinstance(x+y, d.get('T'))"""
# self.check(b, a)
-#
+#
# b = """type( x + y) is d.get('T')"""
# a = """isinstance(x + y, d.get('T'))"""
# self.check(b, a)
-#
+#
# def test_is_not_simple(self):
# b = """type(x) is not T"""
# a = """not isinstance(x, T)"""
# self.check(b, a)
-#
+#
# b = """if type(x) is not T: pass"""
# a = """if not isinstance(x, T): pass"""
# self.check(b, a)
-#
+#
# def test_is_not_reverse(self):
# b = """T is not type(x)"""
# a = """not isinstance(x, T)"""
# self.check(b, a)
-#
+#
# b = """if T is not type(x): pass"""
# a = """if not isinstance(x, T): pass"""
# self.check(b, a)
-#
+#
# def test_is_not_expression(self):
# b = """type(x+y) is not d.get('T')"""
# a = """not isinstance(x+y, d.get('T'))"""
# self.check(b, a)
-#
+#
# b = """type( x + y) is not d.get('T')"""
# a = """not isinstance(x + y, d.get('T'))"""
# self.check(b, a)
-#
+#
# def test_ne_simple(self):
# b = """type(x) != T"""
# a = """not isinstance(x, T)"""
# self.check(b, a)
-#
+#
# b = """if type(x) != T: pass"""
# a = """if not isinstance(x, T): pass"""
# self.check(b, a)
-#
+#
# def test_ne_reverse(self):
# b = """T != type(x)"""
# a = """not isinstance(x, T)"""
# self.check(b, a)
-#
+#
# b = """if T != type(x): pass"""
# a = """if not isinstance(x, T): pass"""
# self.check(b, a)
-#
+#
# def test_ne_expression(self):
# b = """type(x+y) != d.get('T')"""
# a = """not isinstance(x+y, d.get('T'))"""
# self.check(b, a)
-#
+#
# b = """type( x + y) != d.get('T')"""
# a = """not isinstance(x + y, d.get('T'))"""
# self.check(b, a)
-#
+#
# def test_type_unchanged(self):
# a = """type(x).__name__"""
# self.unchanged(a)
-#
+#
# def test_sort_list_call(self):
# b = """
# v = list(t)
@@ -3249,7 +3301,7 @@ def test_with_future_print_function(self):
# foo(v)
# """
# self.check(b, a)
-#
+#
# b = """
# v = list(foo(b) + d)
# v.sort()
@@ -3260,7 +3312,7 @@ def test_with_future_print_function(self):
# foo(v)
# """
# self.check(b, a)
-#
+#
# b = """
# while x:
# v = list(t)
@@ -3273,7 +3325,7 @@ def test_with_future_print_function(self):
# foo(v)
# """
# self.check(b, a)
-#
+#
# b = """
# v = list(t)
# # foo
@@ -3286,7 +3338,7 @@ def test_with_future_print_function(self):
# foo(v)
# """
# self.check(b, a)
-#
+#
# b = r"""
# v = list( t)
# v.sort()
@@ -3297,21 +3349,21 @@ def test_with_future_print_function(self):
# foo(v)
# """
# self.check(b, a)
-#
+#
# b = r"""
# try:
# m = list(s)
# m.sort()
# except: pass
# """
-#
+#
# a = r"""
# try:
# m = sorted(s)
# except: pass
# """
# self.check(b, a)
-#
+#
# b = r"""
# try:
# m = list(s)
@@ -3319,7 +3371,7 @@ def test_with_future_print_function(self):
# m.sort()
# except: pass
# """
-#
+#
# a = r"""
# try:
# m = sorted(s)
@@ -3327,17 +3379,17 @@ def test_with_future_print_function(self):
# except: pass
# """
# self.check(b, a)
-#
+#
# b = r"""
# m = list(s)
# # more comments
# m.sort()"""
-#
+#
# a = r"""
# m = sorted(s)
# # more comments"""
# self.check(b, a)
-#
+#
# def test_sort_simple_expr(self):
# b = """
# v = t
@@ -3349,7 +3401,7 @@ def test_with_future_print_function(self):
# foo(v)
# """
# self.check(b, a)
-#
+#
# b = """
# v = foo(b)
# v.sort()
@@ -3360,7 +3412,7 @@ def test_with_future_print_function(self):
# foo(v)
# """
# self.check(b, a)
-#
+#
# b = """
# v = b.keys()
# v.sort()
@@ -3371,7 +3423,7 @@ def test_with_future_print_function(self):
# foo(v)
# """
# self.check(b, a)
-#
+#
# b = """
# v = foo(b) + d
# v.sort()
@@ -3382,7 +3434,7 @@ def test_with_future_print_function(self):
# foo(v)
# """
# self.check(b, a)
-#
+#
# b = """
# while x:
# v = t
@@ -3395,7 +3447,7 @@ def test_with_future_print_function(self):
# foo(v)
# """
# self.check(b, a)
-#
+#
# b = """
# v = t
# # foo
@@ -3408,7 +3460,7 @@ def test_with_future_print_function(self):
# foo(v)
# """
# self.check(b, a)
-#
+#
# b = r"""
# v = t
# v.sort()
@@ -3419,7 +3471,7 @@ def test_with_future_print_function(self):
# foo(v)
# """
# self.check(b, a)
-#
+#
# def test_sort_unchanged(self):
# s = """
# v = list(t)
@@ -3427,57 +3479,57 @@ def test_with_future_print_function(self):
# foo(w)
# """
# self.unchanged(s)
-#
+#
# s = """
# v = list(t)
# v.sort(u)
# foo(v)
# """
# self.unchanged(s)
-#
+#
# class Test_basestring(FixerTestCase):
# fixer = "basestring"
-#
+#
# def test_basestring(self):
# b = """isinstance(x, basestring)"""
# a = """isinstance(x, str)"""
# self.check(b, a)
-#
+#
# class Test_buffer(FixerTestCase):
# fixer = "buffer"
-#
+#
# def test_buffer(self):
# b = """x = buffer(y)"""
# a = """x = memoryview(y)"""
# self.check(b, a)
-#
+#
# def test_slicing(self):
# b = """buffer(y)[4:5]"""
# a = """memoryview(y)[4:5]"""
# self.check(b, a)
-#
+#
# class Test_future(FixerTestCase):
# fixer = "future"
-#
+#
# def test_future(self):
# b = """from __future__ import braces"""
# a = """"""
# self.check(b, a)
-#
+#
# b = """# comment\nfrom __future__ import braces"""
# a = """# comment\n"""
# self.check(b, a)
-#
+#
# b = """from __future__ import braces\n# comment"""
# a = """\n# comment"""
# self.check(b, a)
-#
+#
# def test_run_order(self):
# self.assert_runs_after('print')
-#
+#
# class Test_itertools(FixerTestCase):
# fixer = "itertools"
-#
+#
# def checkall(self, before, after):
# # Because we need to check with and without the itertools prefix
# # and on each of the three functions, these loops make it all
@@ -3487,132 +3539,132 @@ def test_with_future_print_function(self):
# b = before %(i+'i'+f)
# a = after %(f)
# self.check(b, a)
-#
+#
# def test_0(self):
# # A simple example -- test_1 covers exactly the same thing,
# # but it's not quite as clear.
# b = "itertools.izip(a, b)"
# a = "zip(a, b)"
# self.check(b, a)
-#
+#
# def test_1(self):
# b = """%s(f, a)"""
# a = """%s(f, a)"""
# self.checkall(b, a)
-#
+#
# def test_qualified(self):
# b = """itertools.ifilterfalse(a, b)"""
# a = """itertools.filterfalse(a, b)"""
# self.check(b, a)
-#
+#
# b = """itertools.izip_longest(a, b)"""
# a = """itertools.zip_longest(a, b)"""
# self.check(b, a)
-#
+#
# def test_2(self):
# b = """ifilterfalse(a, b)"""
# a = """filterfalse(a, b)"""
# self.check(b, a)
-#
+#
# b = """izip_longest(a, b)"""
# a = """zip_longest(a, b)"""
# self.check(b, a)
-#
+#
# def test_space_1(self):
# b = """ %s(f, a)"""
# a = """ %s(f, a)"""
# self.checkall(b, a)
-#
+#
# def test_space_2(self):
# b = """ itertools.ifilterfalse(a, b)"""
# a = """ itertools.filterfalse(a, b)"""
# self.check(b, a)
-#
+#
# b = """ itertools.izip_longest(a, b)"""
# a = """ itertools.zip_longest(a, b)"""
# self.check(b, a)
-#
+#
# def test_run_order(self):
# self.assert_runs_after('map', 'zip', 'filter')
-#
-#
+#
+#
# class Test_itertools_imports(FixerTestCase):
# fixer = 'itertools_imports'
-#
+#
# def test_reduced(self):
# b = "from itertools import imap, izip, foo"
# a = "from itertools import foo"
# self.check(b, a)
-#
+#
# b = "from itertools import bar, imap, izip, foo"
# a = "from itertools import bar, foo"
# self.check(b, a)
-#
+#
# b = "from itertools import chain, imap, izip"
# a = "from itertools import chain"
# self.check(b, a)
-#
+#
# def test_comments(self):
# b = "#foo\nfrom itertools import imap, izip"
# a = "#foo\n"
# self.check(b, a)
-#
+#
# def test_none(self):
# b = "from itertools import imap, izip"
# a = ""
# self.check(b, a)
-#
+#
# b = "from itertools import izip"
# a = ""
# self.check(b, a)
-#
+#
# def test_import_as(self):
# b = "from itertools import izip, bar as bang, imap"
# a = "from itertools import bar as bang"
# self.check(b, a)
-#
+#
# b = "from itertools import izip as _zip, imap, bar"
# a = "from itertools import bar"
# self.check(b, a)
-#
+#
# b = "from itertools import imap as _map"
# a = ""
# self.check(b, a)
-#
+#
# b = "from itertools import imap as _map, izip as _zip"
# a = ""
# self.check(b, a)
-#
+#
# s = "from itertools import bar as bang"
# self.unchanged(s)
-#
+#
# def test_ifilter_and_zip_longest(self):
# for name in "filterfalse", "zip_longest":
# b = "from itertools import i%s" % (name,)
# a = "from itertools import %s" % (name,)
# self.check(b, a)
-#
+#
# b = "from itertools import imap, i%s, foo" % (name,)
# a = "from itertools import %s, foo" % (name,)
# self.check(b, a)
-#
+#
# b = "from itertools import bar, i%s, foo" % (name,)
# a = "from itertools import bar, %s, foo" % (name,)
# self.check(b, a)
-#
+#
# def test_import_star(self):
# s = "from itertools import *"
# self.unchanged(s)
-#
-#
+#
+#
# def test_unchanged(self):
# s = "from itertools import foo"
# self.unchanged(s)
-#
-#
+#
+#
# class Test_import(FixerTestCase):
# fixer = "import"
-#
+#
# def setUp(self):
# super(Test_import, self).setUp()
# # Need to replace fix_import's exists method
@@ -3623,145 +3675,145 @@ def test_with_future_print_function(self):
# def fake_exists(name):
# self.files_checked.append(name)
# return self.always_exists or (name in self.present_files)
-#
+#
# from lib2to3.fixes import fix_import
# fix_import.exists = fake_exists
-#
+#
# def tearDown(self):
# from lib2to3.fixes import fix_import
# fix_import.exists = os.path.exists
-#
+#
# def check_both(self, b, a):
# self.always_exists = True
# super(Test_import, self).check(b, a)
# self.always_exists = False
# super(Test_import, self).unchanged(b)
-#
+#
# def test_files_checked(self):
# def p(path):
# # Takes a unix path and returns a path with correct separators
# return os.path.pathsep.join(path.split("/"))
-#
+#
# self.always_exists = False
# self.present_files = set(['__init__.py'])
# expected_extensions = ('.py', os.path.sep, '.pyc', '.so', '.sl', '.pyd')
# names_to_test = (p("/spam/eggs.py"), "ni.py", p("../../shrubbery.py"))
-#
+#
# for name in names_to_test:
# self.files_checked = []
# self.filename = name
# self.unchanged("import jam")
-#
+#
# if os.path.dirname(name):
# name = os.path.dirname(name) + '/jam'
# else:
# name = 'jam'
# expected_checks = set(name + ext for ext in expected_extensions)
# expected_checks.add("__init__.py")
-#
+#
# self.assertEqual(set(self.files_checked), expected_checks)
-#
+#
# def test_not_in_package(self):
# s = "import bar"
# self.always_exists = False
# self.present_files = set(["bar.py"])
# self.unchanged(s)
-#
+#
# def test_with_absolute_import_enabled(self):
# s = "from __future__ import absolute_import\nimport bar"
# self.always_exists = False
# self.present_files = set(["__init__.py", "bar.py"])
# self.unchanged(s)
-#
+#
# def test_in_package(self):
# b = "import bar"
# a = "from . import bar"
# self.always_exists = False
# self.present_files = set(["__init__.py", "bar.py"])
# self.check(b, a)
-#
+#
# def test_import_from_package(self):
# b = "import bar"
# a = "from . import bar"
# self.always_exists = False
# self.present_files = set(["__init__.py", "bar" + os.path.sep])
# self.check(b, a)
-#
+#
# def test_already_relative_import(self):
# s = "from . import bar"
# self.unchanged(s)
-#
+#
# def test_comments_and_indent(self):
# b = "import bar # Foo"
# a = "from . import bar # Foo"
# self.check(b, a)
-#
+#
# def test_from(self):
# b = "from foo import bar, baz"
# a = "from .foo import bar, baz"
# self.check_both(b, a)
-#
+#
# b = "from foo import bar"
# a = "from .foo import bar"
# self.check_both(b, a)
-#
+#
# b = "from foo import (bar, baz)"
# a = "from .foo import (bar, baz)"
# self.check_both(b, a)
-#
+#
# def test_dotted_from(self):
# b = "from green.eggs import ham"
# a = "from .green.eggs import ham"
# self.check_both(b, a)
-#
+#
# def test_from_as(self):
# b = "from green.eggs import ham as spam"
# a = "from .green.eggs import ham as spam"
# self.check_both(b, a)
-#
+#
# def test_import(self):
# b = "import foo"
# a = "from . import foo"
# self.check_both(b, a)
-#
+#
# b = "import foo, bar"
# a = "from . import foo, bar"
# self.check_both(b, a)
-#
+#
# b = "import foo, bar, x"
# a = "from . import foo, bar, x"
# self.check_both(b, a)
-#
+#
# b = "import x, y, z"
# a = "from . import x, y, z"
# self.check_both(b, a)
-#
+#
# def test_import_as(self):
# b = "import foo as x"
# a = "from . import foo as x"
# self.check_both(b, a)
-#
+#
# b = "import a as b, b as c, c as d"
# a = "from . import a as b, b as c, c as d"
# self.check_both(b, a)
-#
+#
# def test_local_and_absolute(self):
# self.always_exists = False
# self.present_files = set(["foo.py", "__init__.py"])
-#
+#
# s = "import foo, bar"
# self.warns_unchanged(s, "absolute and local imports together")
-#
+#
# def test_dotted_import(self):
# b = "import foo.bar"
# a = "from . import foo.bar"
# self.check_both(b, a)
-#
+#
# def test_dotted_import_as(self):
# b = "import foo.bar as bang"
# a = "from . import foo.bar as bang"
# self.check_both(b, a)
-#
+#
# def test_prefix(self):
# b = """
# # prefix
@@ -3772,101 +3824,101 @@ def test_with_future_print_function(self):
# from . import foo.bar
# """
# self.check_both(b, a)
-#
-#
+#
+#
# class Test_set_literal(FixerTestCase):
-#
+#
# fixer = "set_literal"
-#
+#
# def test_basic(self):
# b = """set([1, 2, 3])"""
# a = """{1, 2, 3}"""
# self.check(b, a)
-#
+#
# b = """set((1, 2, 3))"""
# a = """{1, 2, 3}"""
# self.check(b, a)
-#
+#
# b = """set((1,))"""
# a = """{1}"""
# self.check(b, a)
-#
+#
# b = """set([1])"""
# self.check(b, a)
-#
+#
# b = """set((a, b))"""
# a = """{a, b}"""
# self.check(b, a)
-#
+#
# b = """set([a, b])"""
# self.check(b, a)
-#
+#
# b = """set((a*234, f(args=23)))"""
# a = """{a*234, f(args=23)}"""
# self.check(b, a)
-#
+#
# b = """set([a*23, f(23)])"""
# a = """{a*23, f(23)}"""
# self.check(b, a)
-#
+#
# b = """set([a-234**23])"""
# a = """{a-234**23}"""
# self.check(b, a)
-#
+#
# def test_listcomps(self):
# b = """set([x for x in y])"""
# a = """{x for x in y}"""
# self.check(b, a)
-#
+#
# b = """set([x for x in y if x == m])"""
# a = """{x for x in y if x == m}"""
# self.check(b, a)
-#
+#
# b = """set([x for x in y for a in b])"""
# a = """{x for x in y for a in b}"""
# self.check(b, a)
-#
+#
# b = """set([f(x) - 23 for x in y])"""
# a = """{f(x) - 23 for x in y}"""
# self.check(b, a)
-#
+#
# def test_whitespace(self):
# b = """set( [1, 2])"""
# a = """{1, 2}"""
# self.check(b, a)
-#
+#
# b = """set([1 , 2])"""
# a = """{1 , 2}"""
# self.check(b, a)
-#
+#
# b = """set([ 1 ])"""
# a = """{ 1 }"""
# self.check(b, a)
-#
+#
# b = """set( [1] )"""
# a = """{1}"""
# self.check(b, a)
-#
+#
# b = """set([ 1, 2 ])"""
# a = """{ 1, 2 }"""
# self.check(b, a)
-#
+#
# b = """set([x for x in y ])"""
# a = """{x for x in y }"""
# self.check(b, a)
-#
+#
# b = """set(
# [1, 2]
# )
# """
# a = """{1, 2}\n"""
# self.check(b, a)
-#
+#
# def test_comments(self):
# b = """set((1, 2)) # Hi"""
# a = """{1, 2} # Hi"""
# self.check(b, a)
-#
+#
# # This isn't optimal behavior, but the fixer is optional.
# b = """
# # Foo
@@ -3879,124 +3931,124 @@ def test_with_future_print_function(self):
# {1, 2}
# """
# self.check(b, a)
-#
+#
# def test_unchanged(self):
# s = """set()"""
# self.unchanged(s)
-#
+#
# s = """set(a)"""
# self.unchanged(s)
-#
+#
# s = """set(a, b, c)"""
# self.unchanged(s)
-#
+#
# # Don't transform generators because they might have to be lazy.
# s = """set(x for x in y)"""
# self.unchanged(s)
-#
+#
# s = """set(x for x in y if z)"""
# self.unchanged(s)
-#
+#
# s = """set(a*823-23**2 + f(23))"""
# self.unchanged(s)
-#
-#
+#
+#
# class Test_sys_exc(FixerTestCase):
# fixer = "sys_exc"
-#
+#
# def test_0(self):
# b = "sys.exc_type"
# a = "sys.exc_info()[0]"
# self.check(b, a)
-#
+#
# def test_1(self):
# b = "sys.exc_value"
# a = "sys.exc_info()[1]"
# self.check(b, a)
-#
+#
# def test_2(self):
# b = "sys.exc_traceback"
# a = "sys.exc_info()[2]"
# self.check(b, a)
-#
+#
# def test_3(self):
# b = "sys.exc_type # Foo"
# a = "sys.exc_info()[0] # Foo"
# self.check(b, a)
-#
+#
# def test_4(self):
# b = "sys. exc_type"
# a = "sys. exc_info()[0]"
# self.check(b, a)
-#
+#
# def test_5(self):
# b = "sys .exc_type"
# a = "sys .exc_info()[0]"
# self.check(b, a)
-#
-#
+#
+#
# class Test_paren(FixerTestCase):
# fixer = "paren"
-#
+#
# def test_0(self):
# b = """[i for i in 1, 2 ]"""
# a = """[i for i in (1, 2) ]"""
# self.check(b, a)
-#
+#
# def test_1(self):
# b = """[i for i in 1, 2, ]"""
# a = """[i for i in (1, 2,) ]"""
# self.check(b, a)
-#
+#
# def test_2(self):
# b = """[i for i in 1, 2 ]"""
# a = """[i for i in (1, 2) ]"""
# self.check(b, a)
-#
+#
# def test_3(self):
# b = """[i for i in 1, 2 if i]"""
# a = """[i for i in (1, 2) if i]"""
# self.check(b, a)
-#
+#
# def test_4(self):
# b = """[i for i in 1, 2 ]"""
# a = """[i for i in (1, 2) ]"""
# self.check(b, a)
-#
+#
# def test_5(self):
# b = """(i for i in 1, 2)"""
# a = """(i for i in (1, 2))"""
# self.check(b, a)
-#
+#
# def test_6(self):
# b = """(i for i in 1 ,2 if i)"""
# a = """(i for i in (1 ,2) if i)"""
# self.check(b, a)
-#
+#
# def test_unchanged_0(self):
# s = """[i for i in (1, 2)]"""
# self.unchanged(s)
-#
+#
# def test_unchanged_1(self):
# s = """[i for i in foo()]"""
# self.unchanged(s)
-#
+#
# def test_unchanged_2(self):
# s = """[i for i in (1, 2) if nothing]"""
# self.unchanged(s)
-#
+#
# def test_unchanged_3(self):
# s = """(i for i in (1, 2))"""
# self.unchanged(s)
-#
+#
# def test_unchanged_4(self):
# s = """[i for i in m]"""
# self.unchanged(s)
-#
+#
# class Test_metaclass(FixerTestCase):
-#
+#
# fixer = 'metaclass'
-#
+#
# def test_unchanged(self):
# self.unchanged("class X(): pass")
# self.unchanged("class X(object): pass")
@@ -4005,19 +4057,19 @@ def test_with_future_print_function(self):
# self.unchanged("class X(metaclass=Meta): pass")
# self.unchanged("class X(b, arg=23, metclass=Meta): pass")
# self.unchanged("class X(b, arg=23, metaclass=Meta, other=42): pass")
-#
+#
# s = """
# class X:
# def __metaclass__(self): pass
# """
# self.unchanged(s)
-#
+#
# s = """
# class X:
# a[23] = 74
# """
# self.unchanged(s)
-#
+#
# def test_comments(self):
# b = """
# class X:
@@ -4030,7 +4082,7 @@ def test_with_future_print_function(self):
# pass
# """
# self.check(b, a)
-#
+#
# b = """
# class X:
# __metaclass__ = Meta
@@ -4042,7 +4094,7 @@ def test_with_future_print_function(self):
# # Bedtime!
# """
# self.check(b, a)
-#
+#
# def test_meta(self):
# # no-parent class, odd body
# b = """
@@ -4055,13 +4107,13 @@ def test_with_future_print_function(self):
# pass
# """
# self.check(b, a)
-#
+#
# # one parent class, no body
# b = """class X(object): __metaclass__ = Q"""
# a = """class X(object, metaclass=Q): pass"""
# self.check(b, a)
-#
-#
+#
+#
# # one parent, simple body
# b = """
# class X(object):
@@ -4073,7 +4125,7 @@ def test_with_future_print_function(self):
# bar = 7
# """
# self.check(b, a)
-#
+#
# b = """
# class X:
# __metaclass__ = Meta; x = 4; g = 23
@@ -4083,7 +4135,7 @@ def test_with_future_print_function(self):
# x = 4; g = 23
# """
# self.check(b, a)
-#
+#
# # one parent, simple body, __metaclass__ last
# b = """
# class X(object):
@@ -4095,7 +4147,7 @@ def test_with_future_print_function(self):
# bar = 7
# """
# self.check(b, a)
-#
+#
# # redefining __metaclass__
# b = """
# class X():
@@ -4108,7 +4160,7 @@ def test_with_future_print_function(self):
# bar = 7
# """
# self.check(b, a)
-#
+#
# # multiple inheritance, simple body
# b = """
# class X(clsA, clsB):
@@ -4120,12 +4172,12 @@ def test_with_future_print_function(self):
# bar = 7
# """
# self.check(b, a)
-#
+#
# # keywords in the class statement
# b = """class m(a, arg=23): __metaclass__ = Meta"""
# a = """class m(a, arg=23, metaclass=Meta): pass"""
# self.check(b, a)
-#
+#
# b = """
# class X(expression(2 + 4)):
# __metaclass__ = Meta
@@ -4135,7 +4187,7 @@ def test_with_future_print_function(self):
# pass
# """
# self.check(b, a)
-#
+#
# b = """
# class X(expression(2 + 4), x**4):
# __metaclass__ = Meta
@@ -4145,7 +4197,7 @@ def test_with_future_print_function(self):
# pass
# """
# self.check(b, a)
-#
+#
# b = """
# class X:
# __metaclass__ = Meta
@@ -4156,44 +4208,44 @@ def test_with_future_print_function(self):
# save.py = 23
# """
# self.check(b, a)
-#
-#
+#
+#
# class Test_getcwdu(FixerTestCase):
-#
+#
# fixer = 'getcwdu'
-#
+#
# def test_basic(self):
# b = """os.getcwdu"""
# a = """os.getcwd"""
# self.check(b, a)
-#
+#
# b = """os.getcwdu()"""
# a = """os.getcwd()"""
# self.check(b, a)
-#
+#
# b = """meth = os.getcwdu"""
# a = """meth = os.getcwd"""
# self.check(b, a)
-#
+#
# b = """os.getcwdu(args)"""
# a = """os.getcwd(args)"""
# self.check(b, a)
-#
+#
# def test_comment(self):
# b = """os.getcwdu() # Foo"""
# a = """os.getcwd() # Foo"""
# self.check(b, a)
-#
+#
# def test_unchanged(self):
# s = """os.getcwd()"""
# self.unchanged(s)
-#
+#
# s = """getcwdu()"""
# self.unchanged(s)
-#
+#
# s = """os.getcwdb()"""
# self.unchanged(s)
-#
+#
# def test_indentation(self):
# b = """
# if 1:
@@ -4204,124 +4256,124 @@ def test_with_future_print_function(self):
# os.getcwd()
# """
# self.check(b, a)
-#
+#
# def test_multilation(self):
# b = """os .getcwdu()"""
# a = """os .getcwd()"""
# self.check(b, a)
-#
+#
# b = """os. getcwdu"""
# a = """os. getcwd"""
# self.check(b, a)
-#
+#
# b = """os.getcwdu ( )"""
# a = """os.getcwd ( )"""
# self.check(b, a)
-#
-#
+#
+#
# class Test_operator(FixerTestCase):
-#
+#
# fixer = "operator"
-#
+#
# def test_operator_isCallable(self):
# b = "operator.isCallable(x)"
# a = "hasattr(x, '__call__')"
# self.check(b, a)
-#
+#
# def test_operator_sequenceIncludes(self):
# b = "operator.sequenceIncludes(x, y)"
# a = "operator.contains(x, y)"
# self.check(b, a)
-#
+#
# b = "operator .sequenceIncludes(x, y)"
# a = "operator .contains(x, y)"
# self.check(b, a)
-#
+#
# b = "operator. sequenceIncludes(x, y)"
# a = "operator. contains(x, y)"
# self.check(b, a)
-#
+#
# def test_operator_isSequenceType(self):
# b = "operator.isSequenceType(x)"
# a = "import collections\nisinstance(x, collections.Sequence)"
# self.check(b, a)
-#
+#
# def test_operator_isMappingType(self):
# b = "operator.isMappingType(x)"
# a = "import collections\nisinstance(x, collections.Mapping)"
# self.check(b, a)
-#
+#
# def test_operator_isNumberType(self):
# b = "operator.isNumberType(x)"
# a = "import numbers\nisinstance(x, numbers.Number)"
# self.check(b, a)
-#
+#
# def test_operator_repeat(self):
# b = "operator.repeat(x, n)"
# a = "operator.mul(x, n)"
# self.check(b, a)
-#
+#
# b = "operator .repeat(x, n)"
# a = "operator .mul(x, n)"
# self.check(b, a)
-#
+#
# b = "operator. repeat(x, n)"
# a = "operator. mul(x, n)"
# self.check(b, a)
-#
+#
# def test_operator_irepeat(self):
# b = "operator.irepeat(x, n)"
# a = "operator.imul(x, n)"
# self.check(b, a)
-#
+#
# b = "operator .irepeat(x, n)"
# a = "operator .imul(x, n)"
# self.check(b, a)
-#
+#
# b = "operator. irepeat(x, n)"
# a = "operator. imul(x, n)"
# self.check(b, a)
-#
+#
# def test_bare_isCallable(self):
# s = "isCallable(x)"
# t = "You should use 'hasattr(x, '__call__')' here."
# self.warns_unchanged(s, t)
-#
+#
# def test_bare_sequenceIncludes(self):
# s = "sequenceIncludes(x, y)"
# t = "You should use 'operator.contains(x, y)' here."
# self.warns_unchanged(s, t)
-#
+#
# def test_bare_operator_isSequenceType(self):
# s = "isSequenceType(z)"
# t = "You should use 'isinstance(z, collections.Sequence)' here."
# self.warns_unchanged(s, t)
-#
+#
# def test_bare_operator_isMappingType(self):
# s = "isMappingType(x)"
# t = "You should use 'isinstance(x, collections.Mapping)' here."
# self.warns_unchanged(s, t)
-#
+#
# def test_bare_operator_isNumberType(self):
# s = "isNumberType(y)"
# t = "You should use 'isinstance(y, numbers.Number)' here."
# self.warns_unchanged(s, t)
-#
+#
# def test_bare_operator_repeat(self):
# s = "repeat(x, n)"
# t = "You should use 'operator.mul(x, n)' here."
# self.warns_unchanged(s, t)
-#
+#
# def test_bare_operator_irepeat(self):
# s = "irepeat(y, 187)"
# t = "You should use 'operator.imul(y, 187)' here."
# self.warns_unchanged(s, t)
-#
-#
+#
+#
# class Test_exitfunc(FixerTestCase):
-#
+#
# fixer = "exitfunc"
-#
+#
# def test_simple(self):
# b = """
# import sys
@@ -4333,7 +4385,7 @@ def test_with_future_print_function(self):
# atexit.register(my_atexit)
# """
# self.check(b, a)
-#
+#
# def test_names_import(self):
# b = """
# import sys, crumbs
@@ -4344,7 +4396,7 @@ def test_with_future_print_function(self):
# atexit.register(my_func)
# """
# self.check(b, a)
-#
+#
# def test_complex_expression(self):
# b = """
# import sys
@@ -4356,7 +4408,7 @@ def test_with_future_print_function(self):
# atexit.register(do(d)/a()+complex(f=23, g=23)*expression)
# """
# self.check(b, a)
-#
+#
# def test_comments(self):
# b = """
# import sys # Foo
@@ -4368,7 +4420,7 @@ def test_with_future_print_function(self):
# atexit.register(f) # Blah
# """
# self.check(b, a)
-#
+#
# b = """
# import apples, sys, crumbs, larry # Pleasant comments
# sys.exitfunc = func
@@ -4378,7 +4430,7 @@ def test_with_future_print_function(self):
# atexit.register(func)
# """
# self.check(b, a)
-#
+#
# def test_in_a_function(self):
# b = """
# import sys
@@ -4392,15 +4444,15 @@ def test_with_future_print_function(self):
# atexit.register(func)
# """
# self.check(b, a)
-#
+#
# def test_no_sys_import(self):
# b = """sys.exitfunc = f"""
# a = """atexit.register(f)"""
# msg = ("Can't find sys import; Please add an atexit import at the "
# "top of your file.")
# self.warns(b, a, msg)
-#
-#
+#
+#
# def test_unchanged(self):
# s = """f(sys.exitfunc)"""
# self.unchanged(s)
diff --git a/tests/test_future/test_list.py b/tests/test_future/test_list.py
index 6134c74f..16fb84c5 100644
--- a/tests/test_future/test_list.py
+++ b/tests/test_future/test_list.py
@@ -162,12 +162,15 @@ def test_multiple_inheritance(self):
"""
Issue #96 (for newdict instead of newobject)
"""
- import collections
+ if utils.PY2:
+ from collections import Container
+ else:
+ from collections.abc import Container
class Base(list):
pass
- class Foo(Base, collections.Container):
+ class Foo(Base, Container):
def __contains__(self, item):
return False
diff --git a/tests/test_future/test_magicsuper.py b/tests/test_future/test_magicsuper.py
index 8b725d28..e5bbe093 100644
--- a/tests/test_future/test_magicsuper.py
+++ b/tests/test_future/test_magicsuper.py
@@ -133,4 +133,3 @@ def getit(cls):
if __name__ == '__main__':
unittest.main()
-
diff --git a/tests/test_future/test_object.py b/tests/test_future/test_object.py
index 04392074..4f99cb5a 100644
--- a/tests/test_future/test_object.py
+++ b/tests/test_future/test_object.py
@@ -39,7 +39,7 @@ def __str__(self):
assert str(a) == str(b)
def test_implements_py2_iterator(self):
-
+
class Upper(object):
def __init__(self, iterable):
self._iter = iter(iterable)
@@ -57,7 +57,7 @@ def __next__(self):
return 'Next!'
def __iter__(self):
return self
-
+
itr = MyIter()
self.assertEqual(next(itr), 'Next!')
@@ -68,7 +68,7 @@ def __iter__(self):
self.assertEqual(item, 'Next!')
def test_implements_py2_nonzero(self):
-
+
class EvenIsTrue(object):
"""
An integer that evaluates to True if even.
@@ -94,7 +94,7 @@ def test_int_implements_py2_nonzero(self):
maps to __bool__ in case the user redefines __bool__ in a subclass of
newint.
"""
-
+
class EvenIsTrue(int):
"""
An integer that evaluates to True if even.
@@ -137,7 +137,7 @@ class MyClass(object):
def test_isinstance_object_subclass(self):
"""
- This was failing before
+ This was failing before
"""
class A(object):
pass
@@ -209,12 +209,15 @@ def test_multiple_inheritance(self):
"""
Issue #96
"""
- import collections
+ if utils.PY2:
+ from collections import Container
+ else:
+ from collections.abc import Container
class Base(object):
pass
- class Foo(Base, collections.Container):
+ class Foo(Base, Container):
def __contains__(self, item):
return False
@@ -230,6 +233,57 @@ class MetaClass(type):
class TestClass(with_metaclass(MetaClass, object)):
pass
+ def test_bool(self):
+ """
+ Issue #211
+ """
+ from builtins import object
+
+ class ResultSet(object):
+ def __len__(self):
+ return 0
+
+ self.assertTrue(bool(ResultSet()) is False)
+
+ class ResultSet(object):
+ def __len__(self):
+ return 2
+
+ self.assertTrue(bool(ResultSet()) is True)
+
+ def test_bool2(self):
+ """
+ If __bool__ is defined, the presence or absence of __len__ should
+ be irrelevant.
+ """
+ from builtins import object
+
+ class TrueThing(object):
+ def __bool__(self):
+ return True
+ def __len__(self):
+ raise RuntimeError('__len__ should not be called')
+
+ self.assertTrue(bool(TrueThing()))
+
+ class FalseThing(object):
+ def __bool__(self):
+ return False
+ def __len__(self):
+ raise RuntimeError('__len__ should not be called')
+
+ self.assertFalse(bool(FalseThing()))
+
+ def test_cannot_assign_new_attributes_to_object(self):
+ """
+ New attributes cannot be assigned to object() instances in Python.
+ The same should apply to newobject.
+ """
+ from builtins import object
+
+ with self.assertRaises(AttributeError):
+ object().arbitrary_attribute_name = True
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/test_future/test_pasteurize.py b/tests/test_future/test_pasteurize.py
index b09e3cba..2b6e2ee6 100644
--- a/tests/test_future/test_pasteurize.py
+++ b/tests/test_future/test_pasteurize.py
@@ -96,7 +96,7 @@ def test_exception_indentation(self):
def test_urllib_request(self):
"""
Example Python 3 code using the new urllib.request module.
-
+
Does the ``pasteurize`` script handle this?
"""
before = """
@@ -105,7 +105,7 @@ def test_urllib_request(self):
URL = 'http://pypi.python.org/pypi/{}/json'
package = 'future'
-
+
r = urllib.request.urlopen(URL.format(package))
pprint.pprint(r.read())
"""
@@ -115,7 +115,7 @@ def test_urllib_request(self):
URL = 'http://pypi.python.org/pypi/{}/json'
package = 'future'
-
+
r = urllib_request.urlopen(URL.format(package))
pprint.pprint(r.read())
"""
@@ -150,7 +150,7 @@ def test_correct_exit_status(self):
retcode = main([self.textfilename])
self.assertTrue(isinstance(retcode, int)) # i.e. Py2 builtin int
-
+
class TestFuturizeAnnotations(CodeHandler):
@unittest.expectedFailure
def test_return_annotations_alone(self):
@@ -250,7 +250,7 @@ def foo(bar='baz'):
pass
"""
self.unchanged(s, from3=True)
-
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/test_future/test_range.py b/tests/test_future/test_range.py
index c14f168f..dba15228 100644
--- a/tests/test_future/test_range.py
+++ b/tests/test_future/test_range.py
@@ -6,9 +6,15 @@
from future.builtins import range
from future.tests.base import unittest
-from collections import Iterator, Sequence
from operator import attrgetter
+from future.utils import PY2
+
+if PY2:
+ from collections import Iterator, Sequence
+else:
+ from collections.abc import Iterator, Sequence
+
class RangeTests(unittest.TestCase):
def test_range(self):
@@ -26,6 +32,12 @@ def test_equality_range(self):
self.assertEqual(range(0), range(1, 1))
self.assertEqual(range(0, 10, 3), range(0, 11, 3))
+ def test_contains(self):
+ self.assertIn(1, range(2))
+ self.assertNotIn(10, range(2))
+ self.assertNotIn(None, range(2))
+ self.assertNotIn("", range(2))
+
# Use strict equality of attributes when slicing to catch subtle differences
def assertRangesEqual(self, r1, r2):
by_attrs = attrgetter('start', 'stop', 'step')
@@ -186,7 +198,7 @@ def test_rev_stepped_slice_rev_stepped_range(self):
def test_slice_zero_step(self):
msg = '^slice step cannot be zero$'
- with self.assertRaisesRegexp(ValueError, msg):
+ with self.assertRaisesRegex(ValueError, msg):
range(8)[::0]
def test_properties(self):
diff --git a/tests/test_future/test_standard_library.py b/tests/test_future/test_standard_library.py
index 399d587f..3ac5d2d7 100644
--- a/tests/test_future/test_standard_library.py
+++ b/tests/test_future/test_standard_library.py
@@ -30,7 +30,7 @@ def test_can_import_several(self):
"""
This test failed in v0.12-pre if e.g.
future/standard_library/email/header.py contained:
-
+
from future import standard_library
standard_library.remove_hooks()
"""
@@ -134,7 +134,7 @@ def test_disable_hooks(self):
# Imports should succeed again now:
import builtins
- import configparser
+ import html
if utils.PY2:
self.assertTrue(standard_library.detect_hooks())
self.assertTrue(len(old_meta_path) == len(sys.meta_path))
@@ -247,6 +247,13 @@ def test_itertools_zip_longest(self):
self.assertEqual(list(zip_longest(a, b)),
[(1, 2), (2, 4), (None, 6)])
+ def test_ChainMap(self):
+ """
+ Tests whether collections.ChainMap is available.
+ """
+ from collections import ChainMap
+ cm = ChainMap()
+
@unittest.expectedFailure
@unittest.skipIf(utils.PY3, 'generic import tests are for Py2 only')
def test_import_failure_from_module(self):
@@ -271,9 +278,10 @@ def test_import_failure_from_module(self):
with self.assertRaises(CalledProcessError):
output = self._run_test_script('importme1.py')
- def test_configparser(self):
- import configparser
-
+ # Disabled since v0.16.0:
+ # def test_configparser(self):
+ # import configparser
+
def test_copyreg(self):
import copyreg
@@ -282,7 +290,7 @@ def test_pickle(self):
def test_profile(self):
import profile
-
+
def test_stringio(self):
from io import StringIO
s = StringIO(u'test')
@@ -318,7 +326,7 @@ def test_builtins(self):
import builtins
self.assertTrue(hasattr(builtins, 'tuple'))
- # @unittest.skip("ssl support has been stripped out for now ...")
+ @unittest.skip("ssl redirect support on pypi isn't working as expected for now ...")
def test_urllib_request_ssl_redirect(self):
"""
This site redirects to https://...
diff --git a/tests/test_future/test_str.py b/tests/test_future/test_str.py
index 7e37a62f..51085481 100644
--- a/tests/test_future/test_str.py
+++ b/tests/test_future/test_str.py
@@ -258,7 +258,7 @@ def test_str_contains_something(self):
if utils.PY2:
self.assertTrue(b'A' in s)
with self.assertRaises(TypeError):
- bytes(b'A') in s
+ bytes(b'A') in s
with self.assertRaises(TypeError):
65 in s # unlike bytes
@@ -363,6 +363,29 @@ def test_eq(self):
self.assertFalse(b'ABCD' == s)
self.assertFalse(bytes(b'ABCD') == s)
+ # We want to ensure comparison against unknown types return
+ # NotImplemented so that the interpreter can rerun the test with the
+ # other class. We expect the operator to return False if both return
+ # NotImplemented.
+ class OurCustomString(object):
+ def __init__(self, string):
+ self.string = string
+
+ def __eq__(self, other):
+ return NotImplemented
+
+ our_str = OurCustomString("foobar")
+ new_str = str("foobar")
+
+ self.assertFalse(our_str == new_str)
+ self.assertFalse(new_str == our_str)
+ self.assertIs(new_str.__eq__(our_str), NotImplemented)
+ self.assertIs(our_str.__eq__(new_str), NotImplemented)
+
+ def test_hash(self):
+ s = str('ABCD')
+ self.assertIsInstance(hash(s),int)
+
def test_ne(self):
s = str('ABCD')
self.assertNotEqual('A', s)
@@ -382,10 +405,6 @@ def test_cmp(self):
s > 3
with self.assertRaises(TypeError):
s < 1000
- with self.assertRaises(TypeError):
- s > b'XYZ'
- with self.assertRaises(TypeError):
- s < b'XYZ'
with self.assertRaises(TypeError):
s <= 3
with self.assertRaises(TypeError):
@@ -529,12 +548,15 @@ def test_multiple_inheritance(self):
"""
Issue #96 (for newstr instead of newobject)
"""
- import collections
+ if utils.PY2:
+ from collections import Container
+ else:
+ from collections.abc import Container
class Base(str):
pass
- class Foo(Base, collections.Container):
+ class Foo(Base, Container):
def __contains__(self, item):
return False
diff --git a/tests/test_future/test_super.py b/tests/test_future/test_super.py
index 0376c1d8..3cb23d69 100644
--- a/tests/test_future/test_super.py
+++ b/tests/test_future/test_super.py
@@ -170,6 +170,18 @@ class Elite(Dangerous):
self.assertEqual(Elite().walk(), 'Defused')
+ def test_metaclass(self):
+ class Meta(type):
+ def __init__(cls, name, bases, clsdict):
+ super().__init__(name, bases, clsdict)
+
+ try:
+ class Base(object):
+ __metaclass__ = Meta
+ except Exception as e:
+ self.fail('raised %s with a custom metaclass'
+ % type(e).__name__)
+
class TestSuperFromTestDescrDotPy(unittest.TestCase):
"""
diff --git a/tests/test_future/test_surrogateescape.py b/tests/test_future/test_surrogateescape.py
index 0057ba36..7789ce9d 100644
--- a/tests/test_future/test_surrogateescape.py
+++ b/tests/test_future/test_surrogateescape.py
@@ -33,6 +33,12 @@ def test_encode_ascii_surrogateescape(self):
b = payload.encode('ascii', 'surrogateescape')
self.assertEqual(b, b'cMO2c3RhbA\xc3\xa1=\n')
+ def test_encode_ascii_unicode(self):
+ """
+ Verify that exceptions are raised properly.
+ """
+ self.assertRaises(UnicodeEncodeError, u'\N{SNOWMAN}'.encode, 'US-ASCII', 'surrogateescape')
+
@expectedFailurePY2
def test_encode_ascii_surrogateescape_non_newstr(self):
"""
diff --git a/tests/test_future/test_urllib2.py b/tests/test_future/test_urllib2.py
index e7fb4dd7..2d69dad1 100644
--- a/tests/test_future/test_urllib2.py
+++ b/tests/test_future/test_urllib2.py
@@ -691,6 +691,10 @@ def connect_ftp(self, user, passwd, host, port, dirs,
h = NullFTPHandler(data)
h.parent = MockOpener()
+ # MIME guessing works in Python 3.8!
+ guessed_mime = None
+ if sys.hexversion >= 0x03080000:
+ guessed_mime = "image/gif"
for url, host, port, user, passwd, type_, dirs, filename, mimetype in [
("ftp://localhost/foo/bar/baz.html",
"localhost", ftplib.FTP_PORT, "", "", "I",
@@ -709,7 +713,7 @@ def connect_ftp(self, user, passwd, host, port, dirs,
["foo", "bar"], "", None),
("ftp://localhost/baz.gif;type=a",
"localhost", ftplib.FTP_PORT, "", "", "A",
- [], "baz.gif", None), # XXX really this should guess image/gif
+ [], "baz.gif", guessed_mime),
]:
req = Request(url)
req.timeout = None
diff --git a/tests/test_future/test_urllib_response.py b/tests/test_future/test_urllib_response.py
index 27da4a31..e8f4b4f1 100644
--- a/tests/test_future/test_urllib_response.py
+++ b/tests/test_future/test_urllib_response.py
@@ -8,7 +8,7 @@
from future.tests.base import unittest
-class TestFile(object):
+class File(object):
def __init__(self):
self.closed = False
@@ -28,7 +28,7 @@ class Testaddbase(unittest.TestCase):
# TODO(jhylton): Write tests for other functionality of addbase()
def setUp(self):
- self.fp = TestFile()
+ self.fp = File()
self.addbase = urllib_response.addbase(self.fp)
def test_with(self):
diff --git a/tests/test_future/test_urllibnet.py b/tests/test_future/test_urllibnet.py
index f5f59875..6a7b6d64 100644
--- a/tests/test_future/test_urllibnet.py
+++ b/tests/test_future/test_urllibnet.py
@@ -38,7 +38,7 @@ def testURLread(self):
class urlopenNetworkTests(unittest.TestCase):
- """Tests urllib.reqest.urlopen using the network.
+ """Tests urllib.request.urlopen using the network.
These tests are not exhaustive. Assuming that testing using files does a
good job overall of some of the basic interface features. There are no
@@ -109,7 +109,8 @@ def test_getcode(self):
# On Windows, socket handles are not file descriptors; this
# test can't pass on Windows.
- @unittest.skipIf(sys.platform in ('win32',), 'not appropriate for Windows')
+ @unittest.skipIf(sys.platform in ('darwin', 'win32',), 'not appropriate for Windows')
+ @unittest.skipIf(utils.PY36_PLUS, 'test not applicable on Python 3.5 and higher')
@skip26
def test_fileno(self):
# Make sure fd returned by fileno is valid.
diff --git a/tests/test_future/test_utils.py b/tests/test_future/test_utils.py
index e2240ea6..46f5196c 100644
--- a/tests/test_future/test_utils.py
+++ b/tests/test_future/test_utils.py
@@ -4,7 +4,7 @@
"""
from __future__ import absolute_import, unicode_literals, print_function
-import sys
+import re, sys, traceback
from future.builtins import *
from future.utils import (old_div, istext, isbytes, native, PY2, PY3,
native_str, raise_, as_native_str, ensure_new_type,
@@ -18,6 +18,11 @@
TEST_UNICODE_STR = u'ℝεα∂@ßʟ℮ ☂ℯṧт υηḯ¢☺ḓ℮'
+class MyExceptionIssue235(Exception):
+ def __init__(self, a, b):
+ super(MyExceptionIssue235, self).__init__('{0}: {1}'.format(a, b))
+
+
class TestUtils(unittest.TestCase):
def setUp(self):
self.s = TEST_UNICODE_STR
@@ -62,8 +67,8 @@ def test_native_str(self):
for s in inputs:
self.assertEqual(native_str(s), builtin_str(s))
self.assertTrue(isinstance(native_str(s), builtin_str))
-
- def test_native(self):
+
+ def test_native(self):
a = int(10**20) # long int
b = native(a)
self.assertEqual(a, b)
@@ -71,7 +76,7 @@ def test_native(self):
self.assertEqual(type(b), long)
else:
self.assertEqual(type(b), int)
-
+
c = bytes(b'ABC')
d = native(c)
self.assertEqual(c, d)
@@ -79,7 +84,7 @@ def test_native(self):
self.assertEqual(type(d), type(b'Py2 byte-string'))
else:
self.assertEqual(type(d), bytes)
-
+
s = str(u'ABC')
t = native(s)
self.assertEqual(s, t)
@@ -105,18 +110,14 @@ def test_isbytes(self):
self.assertFalse(isbytes(self.s))
self.assertFalse(isbytes(self.s2))
- @unittest.skipIf(PY3, 'test_raise_ currently fails on Py3')
def test_raise_(self):
- """
- The with_value() test currently fails on Py3
- """
- def valerror():
+ def valuerror():
try:
raise ValueError("Apples!")
except Exception as e:
raise_(e)
- self.assertRaises(ValueError, valerror)
+ self.assertRaises(ValueError, valuerror)
def with_value():
raise_(IOError, "This is an error")
@@ -142,6 +143,17 @@ def with_traceback():
except IOError as e:
self.assertEqual(str(e), "An error")
+ class Timeout(BaseException):
+ pass
+
+ self.assertRaises(Timeout, raise_, Timeout)
+ self.assertRaises(Timeout, raise_, Timeout())
+
+ if PY3:
+ self.assertRaisesRegexp(
+ TypeError, "class must derive from BaseException",
+ raise_, int)
+
def test_raise_from_None(self):
try:
try:
@@ -151,7 +163,40 @@ def test_raise_from_None(self):
except ValueError as e:
self.assertTrue(isinstance(e.__context__, TypeError))
self.assertIsNone(e.__cause__)
-
+
+ def test_issue_235(self):
+ def foo():
+ raise MyExceptionIssue235(3, 7)
+
+ def bar():
+ try:
+ foo()
+ except Exception as err:
+ raise_from(ValueError('blue'), err)
+
+ try:
+ bar()
+ except ValueError as e:
+ pass
+ # incorrectly raises a TypeError on Py3 as of v0.15.2.
+
+ def test_raise_custom_exception(self):
+ """
+ Test issue #387.
+ """
+ class CustomException(Exception):
+ def __init__(self, severity, message):
+ super().__init__("custom message of severity %d: %s" % (
+ severity, message))
+
+ def raise_custom_exception():
+ try:
+ raise CustomException(1, "hello")
+ except CustomException:
+ raise_(*sys.exc_info())
+
+ self.assertRaises(CustomException, raise_custom_exception)
+
@skip26
def test_as_native_str(self):
"""
@@ -161,9 +206,9 @@ class MyClass(object):
@as_native_str()
def __repr__(self):
return u'abc'
-
+
obj = MyClass()
-
+
self.assertEqual(repr(obj), 'abc')
if PY2:
self.assertEqual(repr(obj), b'abc')
@@ -186,6 +231,9 @@ def test_ensure_new_type(self):
self.assertEqual(ensure_new_type(i), i2)
self.assertEqual(type(ensure_new_type(i)), int)
+ l = []
+ self.assertIs(ensure_new_type(l), l)
+
def test_bytes_to_native_str(self):
"""
Test for issue #47
@@ -215,7 +263,7 @@ class DatabaseError(Exception):
# Python 2 and 3:
from future.utils import raise_from
-
+
class FileDatabase:
def __init__(self, filename):
try:
@@ -228,7 +276,7 @@ def __init__(self, filename):
fd = FileDatabase('non_existent_file.txt')
except Exception as e:
assert isinstance(e.__cause__, IOError) # FileNotFoundError on
- # Py3.3+ inherits from IOError
+ # Py3.3+ inherits from IOError
def testCauseSyntax(self):
try:
@@ -265,7 +313,6 @@ def test_class_cause(self):
else:
self.fail("No exception raised")
- @expectedFailurePY3
def test_instance_cause(self):
cause = KeyError('blah')
try:
@@ -291,6 +338,69 @@ def __init__(self):
else:
self.fail("No exception raised")
+ def test_single_exception_stacktrace(self):
+ expected = '''Traceback (most recent call last):
+ File "/opt/python-future/tests/test_future/test_utils.py", line 328, in test_single_exception_stacktrace
+ raise CustomException('ERROR')
+'''
+ if PY2:
+ expected += 'CustomException: ERROR\n'
+ else:
+ expected += 'test_future.test_utils.CustomException: ERROR\n'
+
+ try:
+ raise CustomException('ERROR')
+ except:
+ ret = re.sub(r'"[^"]*tests/test_future', '"/opt/python-future/tests/test_future', traceback.format_exc())
+ ret = re.sub(r', line \d+,', ', line 328,', ret)
+ self.assertEqual(expected, ret)
+ else:
+ self.fail('No exception raised')
+
+ if PY2:
+ def test_chained_exceptions_stacktrace(self):
+ expected = '''Traceback (most recent call last):
+ File "/opt/python-future/tests/test_future/test_utils.py", line 1, in test_chained_exceptions_stacktrace
+ raise_from(CustomException('ERROR'), val_err)
+ File "/opt/python-future/src/future/utils/__init__.py", line 1, in raise_from
+ raise e
+CustomException: ERROR
+
+The above exception was the direct cause of the following exception:
+
+ File "/opt/python-future/tests/test_future/test_utils.py", line 1, in test_chained_exceptions_stacktrace
+ raise ValueError('Wooops')
+ValueError: Wooops
+'''
+
+ try:
+ try:
+ raise ValueError('Wooops')
+ except ValueError as val_err:
+ raise_from(CustomException('ERROR'), val_err)
+ except Exception as err:
+ ret = re.sub(r'"[^"]*tests/test_future', '"/opt/python-future/tests/test_future', traceback.format_exc())
+ ret = re.sub(r'"[^"]*future/utils/__init__.py', '"/opt/python-future/src/future/utils/__init__.py', ret)
+ ret = re.sub(r', line \d+,', ', line 1,', ret)
+ self.assertEqual(expected.splitlines(), ret.splitlines())
+ else:
+ self.fail('No exception raised')
+
+
+class CustomException(Exception):
+ if PY2:
+ def __str__(self):
+ try:
+ out = Exception.__str__(self)
+ if hasattr(self, '__cause__') and self.__cause__ and hasattr(self.__cause__, '__traceback__') and self.__cause__.__traceback__:
+ out += '\n\nThe above exception was the direct cause of the following exception:\n\n'
+ out += ''.join(traceback.format_tb(self.__cause__.__traceback__) + ['{0}: {1}'.format(self.__cause__.__class__.__name__, self.__cause__)])
+ return out
+ except Exception as e:
+ print(e)
+ else:
+ pass
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/test_past/test_basestring.py b/tests/test_past/test_basestring.py
index d002095e..6c224b3e 100644
--- a/tests/test_past/test_basestring.py
+++ b/tests/test_past/test_basestring.py
@@ -19,6 +19,25 @@ def test_isinstance(self):
s2 = oldstr(b'abc')
self.assertTrue(isinstance(s2, basestring))
+ def test_issubclass(self):
+ self.assertTrue(issubclass(str, basestring))
+ self.assertTrue(issubclass(bytes, basestring))
+ self.assertTrue(issubclass(basestring, basestring))
+ self.assertFalse(issubclass(int, basestring))
+ self.assertFalse(issubclass(list, basestring))
+ self.assertTrue(issubclass(basestring, object))
+
+ class CustomString(basestring):
+ pass
+ class NotString(object):
+ pass
+ class OldStyleClass:
+ pass
+ self.assertTrue(issubclass(CustomString, basestring))
+ self.assertFalse(issubclass(NotString, basestring))
+ self.assertFalse(issubclass(OldStyleClass, basestring))
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/test_past/test_builtins.py b/tests/test_past/test_builtins.py
index be22b974..d16978ee 100644
--- a/tests/test_past/test_builtins.py
+++ b/tests/test_past/test_builtins.py
@@ -1768,12 +1768,12 @@ def test_baddecorator(self):
# # ("classic int division", DeprecationWarning)):
# if True:
# run_unittest(*args)
-#
+#
# def test_main(verbose=None):
# test_classes = (BuiltinTest, TestSorted)
-#
+#
# _run_unittest(*test_classes)
-#
+#
# # verify reference counting
# if verbose and hasattr(sys, "gettotalrefcount"):
# import gc
diff --git a/tests/test_past/test_misc.py b/tests/test_past/test_misc.py
new file mode 100644
index 00000000..0367b3db
--- /dev/null
+++ b/tests/test_past/test_misc.py
@@ -0,0 +1,53 @@
+# -*- coding: utf-8 -*-
+"""
+Tests for the resurrected Py2-like cmp function
+"""
+
+from __future__ import absolute_import, unicode_literals, print_function
+
+import os.path
+import sys
+import traceback
+from contextlib import contextmanager
+
+from future.tests.base import unittest
+from future.utils import PY3, PY26
+
+if PY3:
+ from past.builtins import cmp
+
+_dir = os.path.dirname(os.path.abspath(__file__))
+sys.path.append(_dir)
+import test_values
+
+
+@contextmanager
+def empty_context_manager(*args, **kwargs):
+ yield dict(args=args, kwargs=kwargs)
+
+
+class TestCmp(unittest.TestCase):
+ def test_cmp(self):
+ for x, y, cmp_python2_value in test_values.cmp_python2_value:
+ if PY26:
+ # set cmp works a bit differently in 2.6, we try to emulate 2.7 behavior, so skip set cmp tests
+ if isinstance(x, set) or isinstance(y, set):
+ continue
+ # to get this to run on python <3.4 which lacks subTest
+ with getattr(self, 'subTest', empty_context_manager)(x=x, y=y):
+ try:
+ past_cmp_value = cmp(x, y)
+ except Exception:
+ past_cmp_value = traceback.format_exc().strip().split('\n')[-1]
+
+ self.assertEqual(cmp_python2_value, past_cmp_value,
+ "expected result matching python2 __builtins__.cmp({x!r},{y!r}) "
+ "== {cmp_python2_value} "
+ "got past.builtins.cmp({x!r},{y!r}) "
+ "== {past_cmp_value} "
+ "".format(x=x, y=y, past_cmp_value=past_cmp_value,
+ cmp_python2_value=cmp_python2_value))
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/test_past/test_olddict.py b/tests/test_past/test_olddict.py
index 4ea2471b..9f210608 100644
--- a/tests/test_past/test_olddict.py
+++ b/tests/test_past/test_olddict.py
@@ -622,7 +622,7 @@ def test_tuple_keyerror(self):
# 'd.update({x2: 2})']:
# with self.assertRaises(CustomException):
# utils.exec_(stmt, locals())
- #
+ #
# def test_resize1(self):
# # Dict resizing bug, found by Jack Jansen in 2.2 CVS development.
# # This version got an assert failure in debug build, infinite loop in
diff --git a/tests/test_past/test_translation.py b/tests/test_past/test_translation.py
index bb263695..2b442d96 100644
--- a/tests/test_past/test_translation.py
+++ b/tests/test_past/test_translation.py
@@ -67,7 +67,7 @@ def write_and_import(self, code, modulename='mymodule'):
# print('Hooks removed')
sys.path.remove(self.tempdir)
return module
-
+
def test_print_statement(self):
code = """
print 'Hello from a Python 2-style print statement!'
@@ -82,7 +82,7 @@ def test_exec_statement(self):
"""
module = self.write_and_import(code, 'execer')
self.assertEqual(module.x, 7)
-
+
def test_div(self):
code = """
x = 3 / 2
@@ -173,14 +173,14 @@ def test_exception_syntax(self):
module = self.write_and_import(code, 'py2_exceptions')
self.assertEqual(module.value, 'string: success!')
-
+
# class TestFuturizeSimple(CodeHandler):
# """
# This class contains snippets of Python 2 code (invalid Python 3) and
# tests for whether they can be imported correctly from Python 3 with the
# import hooks.
# """
-#
+#
# @unittest.expectedFailure
# def test_problematic_string(self):
# """ This string generates a SyntaxError on Python 3 unless it has
@@ -193,7 +193,7 @@ def test_exception_syntax(self):
# s = r'The folder is "C:\Users"'.
# """
# self.convert_check(before, after)
-#
+#
# def test_tobytes(self):
# """
# The --tobytes option converts all UNADORNED string literals 'abcd' to b'abcd'.
@@ -228,7 +228,7 @@ def test_exception_syntax(self):
# s8 = b"pqrs"
# """
# self.convert_check(before, after, tobytes=True)
-#
+#
# @unittest.expectedFailure
# def test_izip(self):
# before = """
@@ -243,7 +243,7 @@ def test_exception_syntax(self):
# pass
# """
# self.convert_check(before, after, stages=(1, 2), ignore_imports=False)
-#
+#
# @unittest.expectedFailure
# def test_no_unneeded_list_calls(self):
# """
@@ -254,14 +254,14 @@ def test_exception_syntax(self):
# pass
# """
# self.unchanged(code)
-#
+#
# def test_xrange(self):
# code = '''
# for i in xrange(10):
# pass
# '''
# self.convert(code)
-#
+#
# @unittest.expectedFailure
# def test_source_coding_utf8(self):
# """
@@ -275,7 +275,7 @@ def test_exception_syntax(self):
# icons = [u"◐", u"◓", u"◑", u"◒"]
# """
# self.unchanged(code)
-#
+#
# def test_exception_syntax(self):
# """
# Test of whether futurize handles the old-style exception syntax
@@ -293,7 +293,7 @@ def test_exception_syntax(self):
# val = e.errno
# """
# self.convert_check(before, after)
-#
+#
# def test_super(self):
# """
# This tests whether futurize keeps the old two-argument super() calls the
@@ -306,7 +306,7 @@ def test_exception_syntax(self):
# super(VerboseList, self).append(item)
# '''
# self.unchanged(code)
-#
+#
# @unittest.expectedFailure
# def test_file(self):
# """
@@ -323,41 +323,41 @@ def test_exception_syntax(self):
# f.close()
# '''
# self.convert_check(before, after)
-#
+#
# def test_apply(self):
# before = '''
# def addup(*x):
# return sum(x)
-#
+#
# assert apply(addup, (10,20)) == 30
# '''
# after = """
# def addup(*x):
# return sum(x)
-#
+#
# assert addup(*(10,20)) == 30
# """
# self.convert_check(before, after)
-#
+#
# @unittest.skip('not implemented yet')
# def test_download_pypi_package_and_test(self, package_name='future'):
# URL = 'http://pypi.python.org/pypi/{0}/json'
-#
+#
# import requests
# r = requests.get(URL.format(package_name))
# pprint.pprint(r.json())
-#
+#
# download_url = r.json()['urls'][0]['url']
# filename = r.json()['urls'][0]['filename']
# # r2 = requests.get(download_url)
# # with open('/tmp/' + filename, 'w') as tarball:
# # tarball.write(r2.content)
-#
+#
# def test_raw_input(self):
# """
# Passes in a string to the waiting input() after futurize
# conversion.
-#
+#
# The code is the first snippet from these docs:
# http://docs.python.org/2/library/2to3.html
# """
@@ -376,13 +376,13 @@ def test_exception_syntax(self):
# greet(name)
# """
# self.convert_check(before, desired, run=False)
-#
+#
# for interpreter in self.interpreters:
# p1 = Popen([interpreter, self.tempdir + 'mytestscript.py'],
# stdout=PIPE, stdin=PIPE, stderr=PIPE)
# (stdout, stderr) = p1.communicate(b'Ed')
# self.assertEqual(stdout, b"What's your name?\nHello, Ed!\n")
-#
+#
# def test_literal_prefixes_are_not_stripped(self):
# """
# Tests to ensure that the u'' and b'' prefixes on unicode strings and
@@ -397,7 +397,7 @@ def test_exception_syntax(self):
# b = b'byte string'
# '''
# self.unchanged(code)
-#
+#
# @unittest.expectedFailure
# def test_division(self):
# """
@@ -411,8 +411,8 @@ def test_exception_syntax(self):
# x = old_div(1, 2)
# """
# self.convert_check(before, after, stages=[1])
-#
-#
+#
+#
# class TestFuturizeRenamedStdlib(CodeHandler):
# def test_renamed_modules(self):
# before = """
@@ -420,7 +420,7 @@ def test_exception_syntax(self):
# import copy_reg
# import cPickle
# import cStringIO
-#
+#
# s = cStringIO.StringIO('blah')
# """
# after = """
@@ -428,18 +428,18 @@ def test_exception_syntax(self):
# import copyreg
# import pickle
# import io
-#
+#
# s = io.StringIO('blah')
# """
# self.convert_check(before, after)
-#
+#
# @unittest.expectedFailure
# def test_urllib_refactor(self):
# # Code like this using urllib is refactored by futurize --stage2 to use
# # the new Py3 module names, but ``future`` doesn't support urllib yet.
# before = """
# import urllib
-#
+#
# URL = 'http://pypi.python.org/pypi/future/json'
# package_name = 'future'
# r = urllib.urlopen(URL.format(package_name))
@@ -447,14 +447,14 @@ def test_exception_syntax(self):
# """
# after = """
# import urllib.request
-#
+#
# URL = 'http://pypi.python.org/pypi/future/json'
# package_name = 'future'
# r = urllib.request.urlopen(URL.format(package_name))
# data = r.read()
# """
# self.convert_check(before, after)
-#
+#
# def test_renamed_copy_reg_and_cPickle_modules(self):
# """
# Example from docs.python.org/2/library/copy_reg.html
@@ -466,11 +466,11 @@ def test_exception_syntax(self):
# class C(object):
# def __init__(self, a):
# self.a = a
-#
+#
# def pickle_c(c):
# print('pickling a C instance...')
# return C, (c.a,)
-#
+#
# copy_reg.pickle(C, pickle_c)
# c = C(1)
# d = copy.copy(c)
@@ -483,23 +483,23 @@ def test_exception_syntax(self):
# class C(object):
# def __init__(self, a):
# self.a = a
-#
+#
# def pickle_c(c):
# print('pickling a C instance...')
# return C, (c.a,)
-#
+#
# copyreg.pickle(C, pickle_c)
# c = C(1)
# d = copy.copy(c)
# p = pickle.dumps(c)
# """
# self.convert_check(before, after)
-#
+#
# @unittest.expectedFailure
# def test_Py2_StringIO_module(self):
# """
# Ideally, there would be a fixer for this. For now:
-#
+#
# TODO: add the Py3 equivalent for this to the docs
# """
# before = """
@@ -515,19 +515,19 @@ def test_exception_syntax(self):
# # instead?
# """
# self.convert_check(before, after)
-#
-#
+#
+#
# class TestFuturizeStage1(CodeHandler):
# # """
# # Tests "stage 1": safe optimizations: modernizing Python 2 code so that it
# # uses print functions, new-style exception syntax, etc.
-#
+#
# # The behaviour should not change and this should introduce no dependency on
# # the ``future`` package. It produces more modern Python 2-only code. The
# # goal is to reduce the size of the real porting patch-set by performing
# # the uncontroversial patches first.
# # """
-#
+#
# def test_apply(self):
# """
# apply() should be changed by futurize --stage1
@@ -535,7 +535,7 @@ def test_exception_syntax(self):
# before = '''
# def f(a, b):
# return a + b
-#
+#
# args = (1, 2)
# assert apply(f, args) == 3
# assert apply(f, ('a', 'b')) == 'ab'
@@ -543,13 +543,13 @@ def test_exception_syntax(self):
# after = '''
# def f(a, b):
# return a + b
-#
+#
# args = (1, 2)
# assert f(*args) == 3
# assert f(*('a', 'b')) == 'ab'
# '''
# self.convert_check(before, after, stages=[1])
-#
+#
# def test_xrange(self):
# """
# xrange should not be changed by futurize --stage1
@@ -559,18 +559,18 @@ def test_exception_syntax(self):
# pass
# '''
# self.unchanged(code, stages=[1])
-#
+#
# @unittest.expectedFailure
# def test_absolute_import_changes(self):
# """
# Implicit relative imports should be converted to absolute or explicit
# relative imports correctly.
-#
+#
# Issue #16 (with porting bokeh/bbmodel.py)
# """
# with open('specialmodels.py', 'w') as f:
# f.write('pass')
-#
+#
# before = """
# import specialmodels.pandasmodel
# specialmodels.pandasmodel.blah()
@@ -581,7 +581,7 @@ def test_exception_syntax(self):
# pandasmodel.blah()
# """
# self.convert_check(before, after, stages=[1])
-#
+#
# def test_safe_futurize_imports(self):
# """
# The standard library module names should not be changed until stage 2
@@ -590,13 +590,13 @@ def test_exception_syntax(self):
# import ConfigParser
# import HTMLParser
# import collections
-#
+#
# ConfigParser.ConfigParser
# HTMLParser.HTMLParser
# d = collections.OrderedDict()
# """
# self.unchanged(before, stages=[1])
-#
+#
# def test_print(self):
# before = """
# print 'Hello'
@@ -605,7 +605,7 @@ def test_exception_syntax(self):
# print('Hello')
# """
# self.convert_check(before, after, stages=[1])
-#
+#
# before = """
# import sys
# print >> sys.stderr, 'Hello', 'world'
@@ -615,16 +615,16 @@ def test_exception_syntax(self):
# print('Hello', 'world', file=sys.stderr)
# """
# self.convert_check(before, after, stages=[1])
-#
+#
# def test_print_already_function(self):
# """
-# Running futurize --stage1 should not add a second set of parentheses
+# Running futurize --stage1 should not add a second set of parentheses
# """
# before = """
# print('Hello')
# """
# self.unchanged(before, stages=[1])
-#
+#
# @unittest.expectedFailure
# def test_print_already_function_complex(self):
# """
@@ -639,7 +639,7 @@ def test_exception_syntax(self):
# print('Hello', 'world', file=sys.stderr)
# """
# self.unchanged(before, stages=[1])
-#
+#
# def test_exceptions(self):
# before = """
# try:
@@ -654,7 +654,7 @@ def test_exception_syntax(self):
# pass
# """
# self.convert_check(before, after, stages=[1])
-#
+#
# @unittest.expectedFailure
# def test_string_exceptions(self):
# """
@@ -674,7 +674,7 @@ def test_exception_syntax(self):
# pass
# """
# self.convert_check(before, after, stages=[1])
-#
+#
# @unittest.expectedFailure
# def test_oldstyle_classes(self):
# """
@@ -689,8 +689,8 @@ def test_exception_syntax(self):
# pass
# """
# self.convert_check(before, after, stages=[1])
-#
-#
+#
+#
# def test_octal_literals(self):
# before = """
# mode = 0644
@@ -699,7 +699,7 @@ def test_exception_syntax(self):
# mode = 0o644
# """
# self.convert_check(before, after)
-#
+#
# def test_long_int_literals(self):
# before = """
# bignumber = 12345678901234567890L
@@ -708,7 +708,7 @@ def test_exception_syntax(self):
# bignumber = 12345678901234567890
# """
# self.convert_check(before, after)
-#
+#
# def test___future___import_position(self):
# """
# Issue #4: __future__ imports inserted too low in file: SyntaxError
@@ -722,13 +722,13 @@ def test_exception_syntax(self):
# #
# # another comment
# #
-#
+#
# CONSTANTS = [ 0, 01, 011, 0111, 012, 02, 021, 0211, 02111, 013 ]
# _RN_LETTERS = "IVXLCDM"
-#
+#
# def my_func(value):
# pass
-#
+#
# ''' Docstring-like comment here '''
# """
# self.convert(code)
@@ -736,4 +736,3 @@ def test_exception_syntax(self):
if __name__ == '__main__':
unittest.main()
-
diff --git a/tests/test_past/test_values.py b/tests/test_past/test_values.py
new file mode 100644
index 00000000..11872084
--- /dev/null
+++ b/tests/test_past/test_values.py
@@ -0,0 +1,225 @@
+from math import pi
+
+inf, nan = float('inf'), float('nan')
+test_values = [
+ 0, 1, 2, -1, -9999999999, 9999999,
+ 0.0, inf, pi,
+ [], [[]], [1, 2, 3],
+ set(), set([1, 2, 3]),
+ " ", "", "1", "dsada saA.", "2", "dsa", b"", b"dsa", b" ",
+ {5: 3}, dict(), dict(a=99), dict(a=1, b=2, c=3), None
+]
+
+# cmp_python2_values are pre-calculated from running cmp under python2 first values are x and y, last is results of cmp
+cmp_python2_value = [[0, 1, -1], [0, 2, -1], [0, -1, 1], [0, -9999999999999999, 1], [0, 9999999999999999, -1],
+ [0, 0.0, 0], [0, inf, -1], [0, 3.141592653589793, -1], [0, [], -1], [0, [[]], -1],
+ [0, [1, 2, 3], -1], [0, '', -1], [0, ' ', -1], [0, '1', -1], [0, 'a bee cd.', -1], [0, '', -1],
+ [0, ' ', -1], [0, '1', -1], [0, 'a bee cd.', -1], [0, set([]), -1], [0, set([1, 2, 3]), -1],
+ [0, {5: 3}, -1], [0, {}, -1], [0, {'a': 99}, -1], [0, {'a': 1, 'c': 3, 'b': 2}, -1],
+ [0, {'a': 99, 'c': 3, 'b': 5}, -1], [0, None, 1], [1, 0, 1], [1, 2, -1], [1, -1, 1],
+ [1, -9999999999999999, 1], [1, 9999999999999999, -1], [1, 0.0, 1], [1, inf, -1],
+ [1, 3.141592653589793, -1], [1, [], -1], [1, [[]], -1], [1, [1, 2, 3], -1], [1, '', -1],
+ [1, ' ', -1], [1, '1', -1], [1, 'a bee cd.', -1], [1, '', -1], [1, ' ', -1], [1, '1', -1],
+ [1, 'a bee cd.', -1], [1, set([]), -1], [1, set([1, 2, 3]), -1], [1, {5: 3}, -1], [1, {}, -1],
+ [1, {'a': 99}, -1], [1, {'a': 1, 'c': 3, 'b': 2}, -1], [1, {'a': 99, 'c': 3, 'b': 5}, -1],
+ [1, None, 1], [2, 0, 1], [2, 1, 1], [2, -1, 1], [2, -9999999999999999, 1],
+ [2, 9999999999999999, -1], [2, 0.0, 1], [2, inf, -1], [2, 3.141592653589793, -1], [2, [], -1],
+ [2, [[]], -1], [2, [1, 2, 3], -1], [2, '', -1], [2, ' ', -1], [2, '1', -1], [2, 'a bee cd.', -1],
+ [2, '', -1], [2, ' ', -1], [2, '1', -1], [2, 'a bee cd.', -1], [2, set([]), -1],
+ [2, set([1, 2, 3]), -1], [2, {5: 3}, -1], [2, {}, -1], [2, {'a': 99}, -1],
+ [2, {'a': 1, 'c': 3, 'b': 2}, -1], [2, {'a': 99, 'c': 3, 'b': 5}, -1], [2, None, 1], [-1, 0, -1],
+ [-1, 1, -1], [-1, 2, -1], [-1, -9999999999999999, 1], [-1, 9999999999999999, -1], [-1, 0.0, -1],
+ [-1, inf, -1], [-1, 3.141592653589793, -1], [-1, [], -1], [-1, [[]], -1], [-1, [1, 2, 3], -1],
+ [-1, '', -1], [-1, ' ', -1], [-1, '1', -1], [-1, 'a bee cd.', -1], [-1, '', -1], [-1, ' ', -1],
+ [-1, '1', -1], [-1, 'a bee cd.', -1], [-1, set([]), -1], [-1, set([1, 2, 3]), -1],
+ [-1, {5: 3}, -1], [-1, {}, -1], [-1, {'a': 99}, -1], [-1, {'a': 1, 'c': 3, 'b': 2}, -1],
+ [-1, {'a': 99, 'c': 3, 'b': 5}, -1], [-1, None, 1], [-9999999999999999, 0, -1],
+ [-9999999999999999, 1, -1], [-9999999999999999, 2, -1], [-9999999999999999, -1, -1],
+ [-9999999999999999, 9999999999999999, -1], [-9999999999999999, 0.0, -1],
+ [-9999999999999999, inf, -1], [-9999999999999999, 3.141592653589793, -1],
+ [-9999999999999999, [], -1], [-9999999999999999, [[]], -1], [-9999999999999999, [1, 2, 3], -1],
+ [-9999999999999999, '', -1], [-9999999999999999, ' ', -1], [-9999999999999999, '1', -1],
+ [-9999999999999999, 'a bee cd.', -1], [-9999999999999999, '', -1], [-9999999999999999, ' ', -1],
+ [-9999999999999999, '1', -1], [-9999999999999999, 'a bee cd.', -1],
+ [-9999999999999999, set([]), -1], [-9999999999999999, set([1, 2, 3]), -1],
+ [-9999999999999999, {5: 3}, -1], [-9999999999999999, {}, -1], [-9999999999999999, {'a': 99}, -1],
+ [-9999999999999999, {'a': 1, 'c': 3, 'b': 2}, -1],
+ [-9999999999999999, {'a': 99, 'c': 3, 'b': 5}, -1], [-9999999999999999, None, 1],
+ [9999999999999999, 0, 1], [9999999999999999, 1, 1], [9999999999999999, 2, 1],
+ [9999999999999999, -1, 1], [9999999999999999, -9999999999999999, 1], [9999999999999999, 0.0, 1],
+ [9999999999999999, inf, -1], [9999999999999999, 3.141592653589793, 1], [9999999999999999, [], -1],
+ [9999999999999999, [[]], -1], [9999999999999999, [1, 2, 3], -1], [9999999999999999, '', -1],
+ [9999999999999999, ' ', -1], [9999999999999999, '1', -1], [9999999999999999, 'a bee cd.', -1],
+ [9999999999999999, '', -1], [9999999999999999, ' ', -1], [9999999999999999, '1', -1],
+ [9999999999999999, 'a bee cd.', -1], [9999999999999999, set([]), -1],
+ [9999999999999999, set([1, 2, 3]), -1], [9999999999999999, {5: 3}, -1], [9999999999999999, {}, -1],
+ [9999999999999999, {'a': 99}, -1], [9999999999999999, {'a': 1, 'c': 3, 'b': 2}, -1],
+ [9999999999999999, {'a': 99, 'c': 3, 'b': 5}, -1], [9999999999999999, None, 1], [0.0, 0, 0],
+ [0.0, 1, -1], [0.0, 2, -1], [0.0, -1, 1], [0.0, -9999999999999999, 1], [0.0, 9999999999999999, -1],
+ [0.0, inf, -1], [0.0, 3.141592653589793, -1], [0.0, [], -1], [0.0, [[]], -1], [0.0, [1, 2, 3], -1],
+ [0.0, '', -1], [0.0, ' ', -1], [0.0, '1', -1], [0.0, 'a bee cd.', -1], [0.0, '', -1],
+ [0.0, ' ', -1], [0.0, '1', -1], [0.0, 'a bee cd.', -1], [0.0, set([]), -1],
+ [0.0, set([1, 2, 3]), -1], [0.0, {5: 3}, -1], [0.0, {}, -1], [0.0, {'a': 99}, -1],
+ [0.0, {'a': 1, 'c': 3, 'b': 2}, -1], [0.0, {'a': 99, 'c': 3, 'b': 5}, -1], [0.0, None, 1],
+ [inf, 0, 1], [inf, 1, 1], [inf, 2, 1], [inf, -1, 1], [inf, -9999999999999999, 1],
+ [inf, 9999999999999999, 1], [inf, 0.0, 1], [inf, 3.141592653589793, 1], [inf, [], -1],
+ [inf, [[]], -1], [inf, [1, 2, 3], -1], [inf, '', -1], [inf, ' ', -1], [inf, '1', -1],
+ [inf, 'a bee cd.', -1], [inf, '', -1], [inf, ' ', -1], [inf, '1', -1], [inf, 'a bee cd.', -1],
+ [inf, set([]), -1], [inf, set([1, 2, 3]), -1], [inf, {5: 3}, -1], [inf, {}, -1],
+ [inf, {'a': 99}, -1], [inf, {'a': 1, 'c': 3, 'b': 2}, -1], [inf, {'a': 99, 'c': 3, 'b': 5}, -1],
+ [inf, None, 1], [3.141592653589793, 0, 1], [3.141592653589793, 1, 1], [3.141592653589793, 2, 1],
+ [3.141592653589793, -1, 1], [3.141592653589793, -9999999999999999, 1],
+ [3.141592653589793, 9999999999999999, -1], [3.141592653589793, 0.0, 1],
+ [3.141592653589793, inf, -1], [3.141592653589793, [], -1], [3.141592653589793, [[]], -1],
+ [3.141592653589793, [1, 2, 3], -1], [3.141592653589793, '', -1], [3.141592653589793, ' ', -1],
+ [3.141592653589793, '1', -1], [3.141592653589793, 'a bee cd.', -1], [3.141592653589793, '', -1],
+ [3.141592653589793, ' ', -1], [3.141592653589793, '1', -1], [3.141592653589793, 'a bee cd.', -1],
+ [3.141592653589793, set([]), -1], [3.141592653589793, set([1, 2, 3]), -1],
+ [3.141592653589793, {5: 3}, -1], [3.141592653589793, {}, -1], [3.141592653589793, {'a': 99}, -1],
+ [3.141592653589793, {'a': 1, 'c': 3, 'b': 2}, -1],
+ [3.141592653589793, {'a': 99, 'c': 3, 'b': 5}, -1], [3.141592653589793, None, 1], [[], 0, 1],
+ [[], 1, 1], [[], 2, 1], [[], -1, 1], [[], -9999999999999999, 1], [[], 9999999999999999, 1],
+ [[], 0.0, 1], [[], inf, 1], [[], 3.141592653589793, 1], [[], [[]], -1], [[], [1, 2, 3], -1],
+ [[], '', -1], [[], ' ', -1], [[], '1', -1], [[], 'a bee cd.', -1], [[], '', -1], [[], ' ', -1],
+ [[], '1', -1], [[], 'a bee cd.', -1], [[], set([]), -1], [[], set([1, 2, 3]), -1], [[], {5: 3}, 1],
+ [[], {}, 1], [[], {'a': 99}, 1], [[], {'a': 1, 'c': 3, 'b': 2}, 1],
+ [[], {'a': 99, 'c': 3, 'b': 5}, 1], [[], None, 1], [[[]], 0, 1], [[[]], 1, 1], [[[]], 2, 1],
+ [[[]], -1, 1], [[[]], -9999999999999999, 1], [[[]], 9999999999999999, 1], [[[]], 0.0, 1],
+ [[[]], inf, 1], [[[]], 3.141592653589793, 1], [[[]], [], 1], [[[]], [1, 2, 3], 1], [[[]], '', -1],
+ [[[]], ' ', -1], [[[]], '1', -1], [[[]], 'a bee cd.', -1], [[[]], '', -1], [[[]], ' ', -1],
+ [[[]], '1', -1], [[[]], 'a bee cd.', -1], [[[]], set([]), -1], [[[]], set([1, 2, 3]), -1],
+ [[[]], {5: 3}, 1], [[[]], {}, 1], [[[]], {'a': 99}, 1], [[[]], {'a': 1, 'c': 3, 'b': 2}, 1],
+ [[[]], {'a': 99, 'c': 3, 'b': 5}, 1], [[[]], None, 1], [[1, 2, 3], 0, 1], [[1, 2, 3], 1, 1],
+ [[1, 2, 3], 2, 1], [[1, 2, 3], -1, 1], [[1, 2, 3], -9999999999999999, 1],
+ [[1, 2, 3], 9999999999999999, 1], [[1, 2, 3], 0.0, 1], [[1, 2, 3], inf, 1],
+ [[1, 2, 3], 3.141592653589793, 1], [[1, 2, 3], [], 1], [[1, 2, 3], [[]], -1], [[1, 2, 3], '', -1],
+ [[1, 2, 3], ' ', -1], [[1, 2, 3], '1', -1], [[1, 2, 3], 'a bee cd.', -1], [[1, 2, 3], '', -1],
+ [[1, 2, 3], ' ', -1], [[1, 2, 3], '1', -1], [[1, 2, 3], 'a bee cd.', -1], [[1, 2, 3], set([]), -1],
+ [[1, 2, 3], set([1, 2, 3]), -1], [[1, 2, 3], {5: 3}, 1], [[1, 2, 3], {}, 1],
+ [[1, 2, 3], {'a': 99}, 1], [[1, 2, 3], {'a': 1, 'c': 3, 'b': 2}, 1],
+ [[1, 2, 3], {'a': 99, 'c': 3, 'b': 5}, 1], [[1, 2, 3], None, 1], ['', 0, 1], ['', 1, 1],
+ ['', 2, 1], ['', -1, 1], ['', -9999999999999999, 1], ['', 9999999999999999, 1], ['', 0.0, 1],
+ ['', inf, 1], ['', 3.141592653589793, 1], ['', [], 1], ['', [[]], 1], ['', [1, 2, 3], 1],
+ ['', ' ', -1], ['', '1', -1], ['', 'a bee cd.', -1], ['', '', 0], ['', ' ', -1], ['', '1', -1],
+ ['', 'a bee cd.', -1], ['', set([]), 1], ['', set([1, 2, 3]), 1], ['', {5: 3}, 1], ['', {}, 1],
+ ['', {'a': 99}, 1], ['', {'a': 1, 'c': 3, 'b': 2}, 1], ['', {'a': 99, 'c': 3, 'b': 5}, 1],
+ ['', None, 1], [' ', 0, 1], [' ', 1, 1], [' ', 2, 1], [' ', -1, 1], [' ', -9999999999999999, 1],
+ [' ', 9999999999999999, 1], [' ', 0.0, 1], [' ', inf, 1], [' ', 3.141592653589793, 1],
+ [' ', [], 1], [' ', [[]], 1], [' ', [1, 2, 3], 1], [' ', '', 1], [' ', '1', -1],
+ [' ', 'a bee cd.', -1], [' ', '', 1], [' ', ' ', 0], [' ', '1', -1], [' ', 'a bee cd.', -1],
+ [' ', set([]), 1], [' ', set([1, 2, 3]), 1], [' ', {5: 3}, 1], [' ', {}, 1], [' ', {'a': 99}, 1],
+ [' ', {'a': 1, 'c': 3, 'b': 2}, 1], [' ', {'a': 99, 'c': 3, 'b': 5}, 1], [' ', None, 1],
+ ['1', 0, 1], ['1', 1, 1], ['1', 2, 1], ['1', -1, 1], ['1', -9999999999999999, 1],
+ ['1', 9999999999999999, 1], ['1', 0.0, 1], ['1', inf, 1], ['1', 3.141592653589793, 1],
+ ['1', [], 1], ['1', [[]], 1], ['1', [1, 2, 3], 1], ['1', '', 1], ['1', ' ', 1],
+ ['1', 'a bee cd.', -1], ['1', '', 1], ['1', ' ', 1], ['1', '1', 0], ['1', 'a bee cd.', -1],
+ ['1', set([]), 1], ['1', set([1, 2, 3]), 1], ['1', {5: 3}, 1], ['1', {}, 1], ['1', {'a': 99}, 1],
+ ['1', {'a': 1, 'c': 3, 'b': 2}, 1], ['1', {'a': 99, 'c': 3, 'b': 5}, 1], ['1', None, 1],
+ ['a bee cd.', 0, 1], ['a bee cd.', 1, 1], ['a bee cd.', 2, 1], ['a bee cd.', -1, 1],
+ ['a bee cd.', -9999999999999999, 1], ['a bee cd.', 9999999999999999, 1], ['a bee cd.', 0.0, 1],
+ ['a bee cd.', inf, 1], ['a bee cd.', 3.141592653589793, 1], ['a bee cd.', [], 1],
+ ['a bee cd.', [[]], 1], ['a bee cd.', [1, 2, 3], 1], ['a bee cd.', '', 1], ['a bee cd.', ' ', 1],
+ ['a bee cd.', '1', 1], ['a bee cd.', '', 1], ['a bee cd.', ' ', 1], ['a bee cd.', '1', 1],
+ ['a bee cd.', 'a bee cd.', 0], ['a bee cd.', set([]), 1], ['a bee cd.', set([1, 2, 3]), 1],
+ ['a bee cd.', {5: 3}, 1], ['a bee cd.', {}, 1], ['a bee cd.', {'a': 99}, 1],
+ ['a bee cd.', {'a': 1, 'c': 3, 'b': 2}, 1], ['a bee cd.', {'a': 99, 'c': 3, 'b': 5}, 1],
+ ['a bee cd.', None, 1], ['', 0, 1], ['', 1, 1], ['', 2, 1], ['', -1, 1],
+ ['', -9999999999999999, 1], ['', 9999999999999999, 1], ['', 0.0, 1], ['', inf, 1],
+ ['', 3.141592653589793, 1], ['', [], 1], ['', [[]], 1], ['', [1, 2, 3], 1], ['', '', 0],
+ ['', ' ', -1], ['', '1', -1], ['', 'a bee cd.', -1], ['', ' ', -1], ['', '1', -1],
+ ['', 'a bee cd.', -1], ['', set([]), 1], ['', set([1, 2, 3]), 1], ['', {5: 3}, 1], ['', {}, 1],
+ ['', {'a': 99}, 1], ['', {'a': 1, 'c': 3, 'b': 2}, 1], ['', {'a': 99, 'c': 3, 'b': 5}, 1],
+ ['', None, 1], [' ', 0, 1], [' ', 1, 1], [' ', 2, 1], [' ', -1, 1], [' ', -9999999999999999, 1],
+ [' ', 9999999999999999, 1], [' ', 0.0, 1], [' ', inf, 1], [' ', 3.141592653589793, 1],
+ [' ', [], 1], [' ', [[]], 1], [' ', [1, 2, 3], 1], [' ', '', 1], [' ', ' ', 0], [' ', '1', -1],
+ [' ', 'a bee cd.', -1], [' ', '', 1], [' ', '1', -1], [' ', 'a bee cd.', -1], [' ', set([]), 1],
+ [' ', set([1, 2, 3]), 1], [' ', {5: 3}, 1], [' ', {}, 1], [' ', {'a': 99}, 1],
+ [' ', {'a': 1, 'c': 3, 'b': 2}, 1], [' ', {'a': 99, 'c': 3, 'b': 5}, 1], [' ', None, 1],
+ ['1', 0, 1], ['1', 1, 1], ['1', 2, 1], ['1', -1, 1], ['1', -9999999999999999, 1],
+ ['1', 9999999999999999, 1], ['1', 0.0, 1], ['1', inf, 1], ['1', 3.141592653589793, 1],
+ ['1', [], 1], ['1', [[]], 1], ['1', [1, 2, 3], 1], ['1', '', 1], ['1', ' ', 1], ['1', '1', 0],
+ ['1', 'a bee cd.', -1], ['1', '', 1], ['1', ' ', 1], ['1', 'a bee cd.', -1], ['1', set([]), 1],
+ ['1', set([1, 2, 3]), 1], ['1', {5: 3}, 1], ['1', {}, 1], ['1', {'a': 99}, 1],
+ ['1', {'a': 1, 'c': 3, 'b': 2}, 1], ['1', {'a': 99, 'c': 3, 'b': 5}, 1], ['1', None, 1],
+ ['a bee cd.', 0, 1], ['a bee cd.', 1, 1], ['a bee cd.', 2, 1], ['a bee cd.', -1, 1],
+ ['a bee cd.', -9999999999999999, 1], ['a bee cd.', 9999999999999999, 1], ['a bee cd.', 0.0, 1],
+ ['a bee cd.', inf, 1], ['a bee cd.', 3.141592653589793, 1], ['a bee cd.', [], 1],
+ ['a bee cd.', [[]], 1], ['a bee cd.', [1, 2, 3], 1], ['a bee cd.', '', 1], ['a bee cd.', ' ', 1],
+ ['a bee cd.', '1', 1], ['a bee cd.', 'a bee cd.', 0], ['a bee cd.', '', 1], ['a bee cd.', ' ', 1],
+ ['a bee cd.', '1', 1], ['a bee cd.', set([]), 1], ['a bee cd.', set([1, 2, 3]), 1],
+ ['a bee cd.', {5: 3}, 1], ['a bee cd.', {}, 1], ['a bee cd.', {'a': 99}, 1],
+ ['a bee cd.', {'a': 1, 'c': 3, 'b': 2}, 1], ['a bee cd.', {'a': 99, 'c': 3, 'b': 5}, 1],
+ ['a bee cd.', None, 1], [set([]), 0, 1], [set([]), 1, 1], [set([]), 2, 1], [set([]), -1, 1],
+ [set([]), -9999999999999999, 1], [set([]), 9999999999999999, 1], [set([]), 0.0, 1],
+ [set([]), inf, 1], [set([]), 3.141592653589793, 1], [set([]), [], 1], [set([]), [[]], 1],
+ [set([]), [1, 2, 3], 1], [set([]), '', -1], [set([]), ' ', -1], [set([]), '1', -1],
+ [set([]), 'a bee cd.', -1], [set([]), '', -1], [set([]), ' ', -1], [set([]), '1', -1],
+ [set([]), 'a bee cd.', -1],
+ [set([]), set([1, 2, 3]), 'TypeError: cannot compare sets using cmp()'], [set([]), {5: 3}, 1],
+ [set([]), {}, 1], [set([]), {'a': 99}, 1], [set([]), {'a': 1, 'c': 3, 'b': 2}, 1],
+ [set([]), {'a': 99, 'c': 3, 'b': 5}, 1], [set([]), None, 1], [set([1, 2, 3]), 0, 1],
+ [set([1, 2, 3]), 1, 1], [set([1, 2, 3]), 2, 1], [set([1, 2, 3]), -1, 1],
+ [set([1, 2, 3]), -9999999999999999, 1], [set([1, 2, 3]), 9999999999999999, 1],
+ [set([1, 2, 3]), 0.0, 1], [set([1, 2, 3]), inf, 1], [set([1, 2, 3]), 3.141592653589793, 1],
+ [set([1, 2, 3]), [], 1], [set([1, 2, 3]), [[]], 1], [set([1, 2, 3]), [1, 2, 3], 1],
+ [set([1, 2, 3]), '', -1], [set([1, 2, 3]), ' ', -1], [set([1, 2, 3]), '1', -1],
+ [set([1, 2, 3]), 'a bee cd.', -1], [set([1, 2, 3]), '', -1], [set([1, 2, 3]), ' ', -1],
+ [set([1, 2, 3]), '1', -1], [set([1, 2, 3]), 'a bee cd.', -1],
+ [set([1, 2, 3]), set([]), 'TypeError: cannot compare sets using cmp()'],
+ [set([1, 2, 3]), {5: 3}, 1], [set([1, 2, 3]), {}, 1], [set([1, 2, 3]), {'a': 99}, 1],
+ [set([1, 2, 3]), {'a': 1, 'c': 3, 'b': 2}, 1], [set([1, 2, 3]), {'a': 99, 'c': 3, 'b': 5}, 1],
+ [set([1, 2, 3]), None, 1], [{5: 3}, 0, 1], [{5: 3}, 1, 1], [{5: 3}, 2, 1], [{5: 3}, -1, 1],
+ [{5: 3}, -9999999999999999, 1], [{5: 3}, 9999999999999999, 1], [{5: 3}, 0.0, 1], [{5: 3}, inf, 1],
+ [{5: 3}, 3.141592653589793, 1], [{5: 3}, [], -1], [{5: 3}, [[]], -1], [{5: 3}, [1, 2, 3], -1],
+ [{5: 3}, '', -1], [{5: 3}, ' ', -1], [{5: 3}, '1', -1], [{5: 3}, 'a bee cd.', -1],
+ [{5: 3}, '', -1], [{5: 3}, ' ', -1], [{5: 3}, '1', -1], [{5: 3}, 'a bee cd.', -1],
+ [{5: 3}, set([]), -1], [{5: 3}, set([1, 2, 3]), -1], [{5: 3}, {}, 1], [{5: 3}, {'a': 99}, -1],
+ [{5: 3}, {'a': 1, 'c': 3, 'b': 2}, -1], [{5: 3}, {'a': 99, 'c': 3, 'b': 5}, -1], [{5: 3}, None, 1],
+ [{}, 0, 1], [{}, 1, 1], [{}, 2, 1], [{}, -1, 1], [{}, -9999999999999999, 1],
+ [{}, 9999999999999999, 1], [{}, 0.0, 1], [{}, inf, 1], [{}, 3.141592653589793, 1], [{}, [], -1],
+ [{}, [[]], -1], [{}, [1, 2, 3], -1], [{}, '', -1], [{}, ' ', -1], [{}, '1', -1],
+ [{}, 'a bee cd.', -1], [{}, '', -1], [{}, ' ', -1], [{}, '1', -1], [{}, 'a bee cd.', -1],
+ [{}, set([]), -1], [{}, set([1, 2, 3]), -1], [{}, {5: 3}, -1], [{}, {'a': 99}, -1],
+ [{}, {'a': 1, 'c': 3, 'b': 2}, -1], [{}, {'a': 99, 'c': 3, 'b': 5}, -1], [{}, None, 1],
+ [{'a': 99}, 0, 1], [{'a': 99}, 1, 1], [{'a': 99}, 2, 1], [{'a': 99}, -1, 1],
+ [{'a': 99}, -9999999999999999, 1], [{'a': 99}, 9999999999999999, 1], [{'a': 99}, 0.0, 1],
+ [{'a': 99}, inf, 1], [{'a': 99}, 3.141592653589793, 1], [{'a': 99}, [], -1], [{'a': 99}, [[]], -1],
+ [{'a': 99}, [1, 2, 3], -1], [{'a': 99}, '', -1], [{'a': 99}, ' ', -1], [{'a': 99}, '1', -1],
+ [{'a': 99}, 'a bee cd.', -1], [{'a': 99}, '', -1], [{'a': 99}, ' ', -1], [{'a': 99}, '1', -1],
+ [{'a': 99}, 'a bee cd.', -1], [{'a': 99}, set([]), -1], [{'a': 99}, set([1, 2, 3]), -1],
+ [{'a': 99}, {5: 3}, 1], [{'a': 99}, {}, 1], [{'a': 99}, {'a': 1, 'c': 3, 'b': 2}, -1],
+ [{'a': 99}, {'a': 99, 'c': 3, 'b': 5}, -1], [{'a': 99}, None, 1], [{'a': 1, 'c': 3, 'b': 2}, 0, 1],
+ [{'a': 1, 'c': 3, 'b': 2}, 1, 1], [{'a': 1, 'c': 3, 'b': 2}, 2, 1],
+ [{'a': 1, 'c': 3, 'b': 2}, -1, 1], [{'a': 1, 'c': 3, 'b': 2}, -9999999999999999, 1],
+ [{'a': 1, 'c': 3, 'b': 2}, 9999999999999999, 1], [{'a': 1, 'c': 3, 'b': 2}, 0.0, 1],
+ [{'a': 1, 'c': 3, 'b': 2}, inf, 1], [{'a': 1, 'c': 3, 'b': 2}, 3.141592653589793, 1],
+ [{'a': 1, 'c': 3, 'b': 2}, [], -1], [{'a': 1, 'c': 3, 'b': 2}, [[]], -1],
+ [{'a': 1, 'c': 3, 'b': 2}, [1, 2, 3], -1], [{'a': 1, 'c': 3, 'b': 2}, '', -1],
+ [{'a': 1, 'c': 3, 'b': 2}, ' ', -1], [{'a': 1, 'c': 3, 'b': 2}, '1', -1],
+ [{'a': 1, 'c': 3, 'b': 2}, 'a bee cd.', -1], [{'a': 1, 'c': 3, 'b': 2}, '', -1],
+ [{'a': 1, 'c': 3, 'b': 2}, ' ', -1], [{'a': 1, 'c': 3, 'b': 2}, '1', -1],
+ [{'a': 1, 'c': 3, 'b': 2}, 'a bee cd.', -1], [{'a': 1, 'c': 3, 'b': 2}, set([]), -1],
+ [{'a': 1, 'c': 3, 'b': 2}, set([1, 2, 3]), -1], [{'a': 1, 'c': 3, 'b': 2}, {5: 3}, 1],
+ [{'a': 1, 'c': 3, 'b': 2}, {}, 1], [{'a': 1, 'c': 3, 'b': 2}, {'a': 99}, 1],
+ [{'a': 1, 'c': 3, 'b': 2}, {'a': 99, 'c': 3, 'b': 5}, -1], [{'a': 1, 'c': 3, 'b': 2}, None, 1],
+ [{'a': 99, 'c': 3, 'b': 5}, 0, 1], [{'a': 99, 'c': 3, 'b': 5}, 1, 1],
+ [{'a': 99, 'c': 3, 'b': 5}, 2, 1], [{'a': 99, 'c': 3, 'b': 5}, -1, 1],
+ [{'a': 99, 'c': 3, 'b': 5}, -9999999999999999, 1],
+ [{'a': 99, 'c': 3, 'b': 5}, 9999999999999999, 1], [{'a': 99, 'c': 3, 'b': 5}, 0.0, 1],
+ [{'a': 99, 'c': 3, 'b': 5}, inf, 1], [{'a': 99, 'c': 3, 'b': 5}, 3.141592653589793, 1],
+ [{'a': 99, 'c': 3, 'b': 5}, [], -1], [{'a': 99, 'c': 3, 'b': 5}, [[]], -1],
+ [{'a': 99, 'c': 3, 'b': 5}, [1, 2, 3], -1], [{'a': 99, 'c': 3, 'b': 5}, '', -1],
+ [{'a': 99, 'c': 3, 'b': 5}, ' ', -1], [{'a': 99, 'c': 3, 'b': 5}, '1', -1],
+ [{'a': 99, 'c': 3, 'b': 5}, 'a bee cd.', -1], [{'a': 99, 'c': 3, 'b': 5}, '', -1],
+ [{'a': 99, 'c': 3, 'b': 5}, ' ', -1], [{'a': 99, 'c': 3, 'b': 5}, '1', -1],
+ [{'a': 99, 'c': 3, 'b': 5}, 'a bee cd.', -1], [{'a': 99, 'c': 3, 'b': 5}, set([]), -1],
+ [{'a': 99, 'c': 3, 'b': 5}, set([1, 2, 3]), -1], [{'a': 99, 'c': 3, 'b': 5}, {5: 3}, 1],
+ [{'a': 99, 'c': 3, 'b': 5}, {}, 1], [{'a': 99, 'c': 3, 'b': 5}, {'a': 99}, 1],
+ [{'a': 99, 'c': 3, 'b': 5}, {'a': 1, 'c': 3, 'b': 2}, 1], [{'a': 99, 'c': 3, 'b': 5}, None, 1],
+ [None, 0, -1], [None, 1, -1], [None, 2, -1], [None, -1, -1], [None, -9999999999999999, -1],
+ [None, 9999999999999999, -1], [None, 0.0, -1], [None, inf, -1], [None, 3.141592653589793, -1],
+ [None, [], -1], [None, [[]], -1], [None, [1, 2, 3], -1], [None, '', -1], [None, ' ', -1],
+ [None, '1', -1], [None, 'a bee cd.', -1], [None, '', -1], [None, ' ', -1], [None, '1', -1],
+ [None, 'a bee cd.', -1], [None, set([]), -1], [None, set([1, 2, 3]), -1], [None, {5: 3}, -1],
+ [None, {}, -1], [None, {'a': 99}, -1], [None, {'a': 1, 'c': 3, 'b': 2}, -1],
+ [None, {'a': 99, 'c': 3, 'b': 5}, -1]]
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy