Skip to content

Commit

Permalink
Fix unit test on PyPy 7.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
avian2 committed Jun 16, 2019
1 parent dc28c90 commit 25f1e23
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/test_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
import subprocess
import sys
import tempfile
import re


here = os.path.dirname(__file__)

# Python 2.7 does not have assertRegex
if not hasattr(unittest.TestCase, 'assertRegex'):
unittest.TestCase.assertRegex = lambda self, text, exp: self.assertTrue(re.search(exp, text))

def get_cmd():
sys_path = os.path.join(here, "..")
Expand Down Expand Up @@ -39,8 +43,8 @@ def test_encoding_error(self):
f = temp(self.TEST_UNICODE.encode('sjis'))
out, err = run(['-e', 'utf8', f.name])

expected = 'Unable to decode input: invalid start byte, start: 0, end: 1\n'
self.assertEqual(err, expected)
# Text after : ... can differ between Python versions
self.assertRegex(err, '^Unable to decode input: ')

def test_file_specified_encoding(self):
f = temp(self.TEST_UNICODE.encode('sjis'))
Expand Down

0 comments on commit 25f1e23

Please sign in to comment.