Skip to content

Commit d56e832

Browse files
committed
Remove Python 2 specific tests
1 parent ebe19cc commit d56e832

File tree

9 files changed

+10
-309
lines changed

9 files changed

+10
-309
lines changed

bpython/test/__init__.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
try:
2-
import unittest2 as unittest
3-
except ImportError:
4-
import unittest
5-
6-
try:
7-
from unittest import mock
8-
except ImportError:
9-
import mock
1+
import unittest
2+
from unittest import mock
103

114
from bpython.translations import init
12-
from bpython._py3compat import py3
135
from six.moves import builtins
146
import os
157

@@ -22,10 +14,7 @@ def setUpClass(cls):
2214

2315
class MagicIterMock(mock.MagicMock):
2416

25-
if py3:
26-
__next__ = mock.Mock(return_value=None)
27-
else:
28-
next = mock.Mock(return_value=None)
17+
__next__ = mock.Mock(return_value=None)
2918

3019

3120
def builtin_target(obj):

bpython/test/test_autocomplete.py

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,9 @@
1616
has_jedi = False
1717

1818
from bpython import autocomplete
19-
from bpython._py3compat import py3
2019
from bpython.test import mock
2120

22-
if py3:
23-
glob_function = "glob.iglob"
24-
else:
25-
glob_function = "glob.glob"
21+
glob_function = "glob.iglob"
2622

2723

2824
class TestSafeEval(unittest.TestCase):
@@ -235,11 +231,6 @@ def method(self, x):
235231
pass
236232

237233

238-
skip_old_style = unittest.skipIf(
239-
py3, "In Python 3 there are no old style classes"
240-
)
241-
242-
243234
class Properties(Foo):
244235
@property
245236
def asserts_when_called(self):
@@ -266,35 +257,6 @@ def test_att_matches_found_on_instance(self):
266257
set(["a.method", "a.a", "a.b"]),
267258
)
268259

269-
@skip_old_style
270-
def test_att_matches_found_on_old_style_instance(self):
271-
self.assertSetEqual(
272-
self.com.matches(2, "a.", locals_={"a": OldStyleFoo()}),
273-
set(["a.method", "a.a", "a.b"]),
274-
)
275-
self.assertIn(
276-
u"a.__dict__",
277-
self.com.matches(4, "a.__", locals_={"a": OldStyleFoo()}),
278-
)
279-
280-
@skip_old_style
281-
def test_att_matches_found_on_old_style_class_object(self):
282-
self.assertIn(
283-
u"A.__dict__",
284-
self.com.matches(4, "A.__", locals_={"A": OldStyleFoo}),
285-
)
286-
287-
@skip_old_style
288-
def test_issue536(self):
289-
class OldStyleWithBrokenGetAttr:
290-
def __getattr__(self, attr):
291-
raise Exception()
292-
293-
locals_ = {"a": OldStyleWithBrokenGetAttr()}
294-
self.assertIn(
295-
u"a.__module__", self.com.matches(4, "a.__", locals_=locals_)
296-
)
297-
298260
def test_descriptor_attributes_not_run(self):
299261
com = autocomplete.AttrCompletion()
300262
self.assertSetEqual(
@@ -327,13 +289,6 @@ def test_att_matches_found_on_instance(self):
327289
set(["method", "a", "b"]),
328290
)
329291

330-
@skip_old_style
331-
def test_att_matches_found_on_old_style_instance(self):
332-
self.assertSetEqual(
333-
self.com.matches(5, "a[0].", locals_={"a": [OldStyleFoo()]}),
334-
set(["method", "a", "b"]),
335-
)
336-
337292
def test_other_getitem_methods_not_called(self):
338293
class FakeList(object):
339294
def __getitem__(inner_self, i):
@@ -438,7 +393,6 @@ def test_completions_starting_with_different_cases(self):
438393
)
439394
self.assertSetEqual(matches, set(["ade"]))
440395

441-
@unittest.skipUnless(py3, "asyncio required")
442396
def test_issue_544(self):
443397
com = autocomplete.MultilineJediCompletion()
444398
code = "@asyncio.coroutine\ndef"
@@ -463,10 +417,6 @@ def test_completions_are_unicode(self):
463417
for m in self.com.matches(1, "a", locals_={"abc": 10}):
464418
self.assertIsInstance(m, type(u""))
465419

466-
@unittest.skipIf(py3, "in Python 3 invalid identifiers are passed through")
467-
def test_ignores_nonascii_encodable(self):
468-
self.assertEqual(self.com.matches(3, "abc", locals_={"abcß": 10}), None)
469-
470420
def test_mock_kwlist(self):
471421
with mock.patch.object(keyword, "kwlist", new=["abcd"]):
472422
self.assertEqual(self.com.matches(3, "abc", locals_={}), None)
@@ -481,11 +431,7 @@ def test_set_of_params_returns_when_matches_found(self):
481431
def func(apple, apricot, banana, carrot):
482432
pass
483433

484-
if py3:
485-
argspec = list(inspect.getfullargspec(func))
486-
else:
487-
argspec = list(inspect.getargspec(func))
488-
434+
argspec = list(inspect.getfullargspec(func))
489435
argspec = ["func", argspec, False]
490436
com = autocomplete.ParameterNameCompletion()
491437
self.assertSetEqual(

bpython/test/test_curtsies_repl.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from bpython import autocomplete
1515
from bpython import config
1616
from bpython import args
17-
from bpython._py3compat import py3
1817
from bpython.test import (
1918
FixLanguageTestCase as TestCase,
2019
MagicIterMock,
@@ -24,13 +23,7 @@
2423
)
2524

2625
from curtsies import events
27-
28-
if py3:
29-
from importlib import invalidate_caches
30-
else:
31-
32-
def invalidate_caches():
33-
"""Does not exist before Python 3.3"""
26+
from importlib import invalidate_caches
3427

3528

3629
def setup_config(conf):
@@ -110,10 +103,7 @@ def test_get_last_word_with_prev_line(self):
110103

111104

112105
def mock_next(obj, return_value):
113-
if py3:
114-
obj.__next__.return_value = return_value
115-
else:
116-
obj.next.return_value = return_value
106+
obj.__next__.return_value = return_value
117107

118108

119109
class TestCurtsiesReplTab(TestCase):

bpython/test/test_import_not_cyclical.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
import sys
33
import tempfile
44

5-
from bpython._py3compat import py3
65
from bpython.test import unittest
76
from bpython.importcompletion import find_modules
87

98

10-
@unittest.skipIf(not py3, "Test doesn't work in python 2.")
119
class TestAvoidSymbolicLinks(unittest.TestCase):
1210
def setUp(self):
1311
with tempfile.TemporaryDirectory() as import_test_folder:

bpython/test/test_inspection.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os
22

3-
from bpython._py3compat import py3
43
from bpython import inspection
54
from bpython.test import unittest
65
from bpython.test.fodder import encoding_ascii
@@ -58,16 +57,6 @@ def test_is_callable(self):
5857
self.assertFalse(inspection.is_callable(None))
5958
self.assertTrue(inspection.is_callable(CallableMethod().method))
6059

61-
@unittest.skipIf(py3, "old-style classes only exist in Python 2")
62-
def test_is_new_style_py2(self):
63-
self.assertTrue(inspection.is_new_style(spam))
64-
self.assertTrue(inspection.is_new_style(Noncallable))
65-
self.assertFalse(inspection.is_new_style(OldNoncallable))
66-
self.assertTrue(inspection.is_new_style(Noncallable()))
67-
self.assertFalse(inspection.is_new_style(OldNoncallable()))
68-
self.assertTrue(inspection.is_new_style(None))
69-
70-
@unittest.skipUnless(py3, "only in Python 3 are all classes new-style")
7160
def test_is_new_style_py3(self):
7261
self.assertTrue(inspection.is_new_style(spam))
7362
self.assertTrue(inspection.is_new_style(Noncallable))
@@ -170,12 +159,6 @@ def prop(self):
170159
class Slots(object):
171160
__slots__ = ["s1", "s2", "s3"]
172161

173-
if not py3:
174-
175-
@property
176-
def s3(self):
177-
raise AssertionError("Property __get__ executed")
178-
179162

180163
class SlotsSubclass(Slots):
181164
@property
@@ -248,14 +231,6 @@ def test_lookup_on_slots_classes(self):
248231
self.assertEqual(inspection.hasattr_safe(s, "s1"), False)
249232
self.assertEqual(inspection.hasattr_safe(s, "s4"), True)
250233

251-
@unittest.skipIf(py3, "Py 3 doesn't allow slots and prop in same class")
252-
def test_lookup_with_property_and_slots(self):
253-
sga = inspection.getattr_safe
254-
s = SlotsSubclass()
255-
self.assertIsInstance(sga(Slots, "s3"), property)
256-
self.assertEqual(inspection.getattr_safe(s, "s3"), Slots.__dict__["s3"])
257-
self.assertIsInstance(sga(SlotsSubclass, "s3"), property)
258-
259234
def test_lookup_on_overridden_methods(self):
260235
sga = inspection.getattr_safe
261236
self.assertEqual(sga(OverriddenGetattr(), "a"), 1)

0 commit comments

Comments
 (0)