Skip to content

Commit e4c3d4d

Browse files
committed
Simplify tests and enable all of them
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
1 parent 9542b0c commit e4c3d4d

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

bpython/test/test_interpreter.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# -*- coding: utf-8 -*-
2+
13
from __future__ import unicode_literals
24

35
try:
@@ -57,40 +59,36 @@ def g():
5759

5860
@unittest.skipIf(py3, "runsource() accepts only unicode in Python 3")
5961
def test_runsource_bytes(self):
60-
i = interpreter.Interp()
61-
i.encoding = 'latin-1'
62+
i = interpreter.Interp(encoding='latin-1')
6263

63-
i.runsource(b"a = b'\xfe'")
64+
i.runsource("a = b'\xfe'".encode('latin-1'), encode=False)
6465
self.assertIsInstance(i.locals['a'], str)
6566
self.assertEqual(i.locals['a'], b"\xfe")
6667

67-
i.runsource(b"b = u'\xfe'")
68+
i.runsource("b = u'\xfe'".encode('latin-1'), encode=False)
6869
self.assertIsInstance(i.locals['b'], unicode)
69-
self.assertEqual(i.locals['b'], u"\xfe")
70+
self.assertEqual(i.locals['b'], "\xfe")
7071

7172
@unittest.skipUnless(py3, "Only a syntax error in Python 3")
7273
@mock.patch.object(interpreter.Interp, 'showsyntaxerror')
7374
def test_runsource_bytes_over_128_syntax_error(self):
74-
i = interpreter.Interp()
75-
i.encoding = 'latin-1'
75+
i = interpreter.Interp(encoding='latin-1')
7676

77-
i.runsource(u"a = b'\xfe'")
77+
i.runsource("a = b'\xfe'", encode=True)
7878
i.showsyntaxerror.assert_called_with()
7979

80-
@unittest.skip("Is the goal of encoding to get this to work?")
81-
@unittest.skipIf(py3, "bytes 128-255 only permitted in Py 2")
80+
@unittest.skipIf(py3, "encode is Python 2 only")
8281
def test_runsource_bytes_over_128_syntax_error(self):
83-
i = interpreter.Interp()
84-
i.encoding = 'latin-1'
82+
i = interpreter.Interp(encoding='latin-1')
8583

86-
i.runsource(u"a = b'\xfe'")
84+
i.runsource("a = b'\xfe'", encode=True)
8785
self.assertIsInstance(i.locals['a'], type(b''))
8886
self.assertEqual(i.locals['a'], b"\xfe")
8987

88+
@unittest.skipIf(py3, "encode is Python 2 only")
9089
def test_runsource_unicode(self):
91-
i = interpreter.Interp()
92-
i.encoding = 'latin-1'
90+
i = interpreter.Interp(encoding='latin-1')
9391

94-
i.runsource(u"a = u'\xfe'")
92+
i.runsource("a = u'\xfe'", encode=True)
9593
self.assertIsInstance(i.locals['a'], type(u''))
9694
self.assertEqual(i.locals['a'], u"\xfe")

0 commit comments

Comments
 (0)