X Tutup
Skip to content

Commit 0b15a0b

Browse files
committed
Use the same unittest2 import block everywhere
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
1 parent b451f95 commit 0b15a0b

12 files changed

+52
-21
lines changed

bpython/test/test_args.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
import unittest
21
import subprocess
32
import sys
43
import tempfile
54
from textwrap import dedent
65

6+
try:
7+
import unittest2 as unittest
8+
except ImportError:
9+
import unittest
710

811
class TestExecArgs(unittest.TestCase):
912
def test_exec_dunder_file(self):

bpython/test/test_config.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import os
2-
import unittest
32
import tempfile
43
import textwrap
54

5+
try:
6+
import unittest2 as unittest
7+
except ImportError:
8+
import unittest
9+
610
from bpython import config
711

812
TEST_THEME_PATH = os.path.join(os.path.dirname(__file__), "test.theme")

bpython/test/test_curtsies_coderunner.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
import unittest
21
import sys
32

3+
try:
4+
import unittest2 as unittest
5+
except ImportError:
6+
import unittest
7+
48
from bpython.curtsiesfrontend.coderunner import CodeRunner, FakeOutput
59

610
class TestCodeRunner(unittest.TestCase):

bpython/test/test_curtsies_painting.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
from contextlib import contextmanager
66

77
try:
8-
from unittest import skip
8+
import unittest2 as unittest
99
except ImportError:
10-
def skip(f):
11-
return lambda self: None
10+
import unittest
1211

1312
from curtsies.formatstringarray import FormatStringTest, fsarray
1413
from curtsies.fmtfuncs import *

bpython/test/test_curtsies_parser.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import unittest
1+
try:
2+
import unittest2 as unittest
3+
except ImportError:
4+
import unittest
25

36
from bpython.curtsiesfrontend import parse
47
from curtsies.fmtfuncs import yellow, cyan, green, bold

bpython/test/test_curtsies_repl.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@
1313
except ImportError:
1414
import unittest
1515

16-
17-
py3 = (sys.version_info[0] == 3)
18-
1916
from bpython.curtsiesfrontend import repl as curtsiesrepl
2017
from bpython.curtsiesfrontend import interpreter
2118
from bpython import autocomplete
2219
from bpython import config
2320
from bpython import args
21+
from bpython._py3compat import py3
2422

2523
def setup_config(conf):
2624
config_struct = config.Struct()

bpython/test/test_importcompletion.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
from bpython import importcompletion
22

3-
import unittest
3+
try:
4+
import unittest2 as unittest
5+
except ImportError:
6+
import unittest
7+
48

59
class TestSimpleComplete(unittest.TestCase):
610

bpython/test/test_inspection.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import unittest
1+
try:
2+
import unittest2 as unittest
3+
except ImportError:
4+
import unittest
25

36
from bpython import inspection
47

bpython/test/test_interpreter.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import unittest
1+
try:
2+
import unittest2 as unittest
3+
except ImportError:
4+
import unittest
25

36
from bpython.curtsiesfrontend import interpreter
47
from curtsies.fmtfuncs import *
@@ -10,7 +13,7 @@ def test_syntaxerror(self):
1013

1114
def append_to_a(message):
1215
a.append(message)
13-
16+
1417
i.write = append_to_a
1518
i.runsource('1.1.1.1')
1619

@@ -25,7 +28,7 @@ def test_traceback(self):
2528

2629
def append_to_a(message):
2730
a.append(message)
28-
31+
2932
i.write = append_to_a
3033

3134
def f():

bpython/test/test_keys.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import unittest
1+
try:
2+
import unittest2 as unittest
3+
except ImportError:
4+
import unittest
5+
26
import bpython.keys as keys
37

48
class TestCLIKeys(unittest.TestCase):

0 commit comments

Comments
 (0)
X Tutup