Skip to content

Commit 27c041f

Browse files
commit test
1 parent b30efb8 commit 27c041f

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

bpython/repl.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,13 @@ def __init__(self, locals=None, encoding=None):
8585
necessarily must be with the current factoring) and then an exception
8686
callback can be added to the Interpreter instance afterwards - more
8787
specifically, this is so that autoindentation does not occur after a
88-
traceback."""
88+
traceback.
89+
90+
encoding is only used in Python 2, where it may be necessary to add an
91+
encoding comment to a source bytestring before running it.
92+
encoding must be a bytestring in Python 2 because it will be templated
93+
into a bytestring source as part of an encoding comment.
94+
"""
8995

9096
self.encoding = encoding or sys.getdefaultencoding()
9197
self.syntaxerror_callback = None

bpython/test/test_args.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1+
# encoding: utf-8
2+
13
import subprocess
24
import sys
35
import tempfile
46
from textwrap import dedent
57

68
from bpython import args
7-
from bpython.test import FixLanguageTestCase as TestCase
8-
9-
try:
10-
import unittest2 as unittest
11-
except ImportError:
12-
import unittest
9+
from bpython.test import (FixLanguageTestCase as TestCase, unittest)
1310

1411
try:
1512
from nose.plugins.attrib import attr
@@ -40,6 +37,22 @@ def test_exec_dunder_file(self):
4037
self.assertEquals(stderr.strip(), f.name)
4138

4239

40+
def test_exec_nonascii_file(self):
41+
with tempfile.NamedTemporaryFile(mode="w") as f:
42+
f.write(dedent('''\
43+
#!/usr/bin/env python2
44+
# coding: utf-8
45+
"你好 # nonascii"
46+
'''))
47+
f.flush()
48+
try:
49+
subprocess.check_call([
50+
'python', '-m', 'bpython.curtsies',
51+
f.name])
52+
except subprocess.CalledProcessError:
53+
self.fail('Error running module with nonascii characters')
54+
55+
4356
class TestParse(TestCase):
4457

4558
def test_version(self):

0 commit comments

Comments
 (0)