Skip to content

Commit 979a67b

Browse files
Merge branch 'fix-497'
2 parents e77ce89 + 83ce5e9 commit 979a67b

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

bpython/repl.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,8 @@ def edit_config(self):
10701070
try:
10711071
default_config = pkgutil.get_data('bpython',
10721072
'sample-config')
1073+
if py3: # py3 files need unicode
1074+
default_config = default_config.decode('ascii')
10731075
bpython_dir, script_name = os.path.split(__file__)
10741076
containing_dir = os.path.dirname(
10751077
os.path.abspath(self.config.config_path))

bpython/sample-config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
# save_append_py = False
4646

4747
# The name of a helper executable that should perform pastebin upload on
48-
# bpythons behalf. If unset, bpython uploads pastes to bpaste.net. (default: )
48+
# bpython's behalf. If unset, bpython uploads pastes to bpaste.net. (default: )
4949
#pastebin_helper = gist.py
5050

5151
# How long an undo must be expected to take before prompting for how

bpython/test/test_repl.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import collections
22
from itertools import islice
33
import os
4+
import shutil
45
import socket
6+
import tempfile
57
from six.moves import range
68

79
try:
@@ -11,7 +13,7 @@
1113

1214
from bpython._py3compat import py3
1315
from bpython import config, repl, cli, autocomplete
14-
from bpython.test import MagicIterMock, mock
16+
from bpython.test import MagicIterMock, mock, FixLanguageTestCase as TestCase
1517

1618

1719
def setup_config(conf):
@@ -252,6 +254,25 @@ def test_current_line(self):
252254
# TODO add tests for various failures without using current function
253255

254256

257+
class TestEditConfig(TestCase):
258+
def setUp(self):
259+
self.repl = FakeRepl()
260+
self.repl.interact.confirm = lambda msg: True
261+
self.repl.interact.notify = lambda msg: None
262+
self.repl.config.editor = 'true'
263+
264+
def test_create_config(self):
265+
tmp_dir = tempfile.mkdtemp()
266+
try:
267+
config_path = os.path.join(tmp_dir, 'newdir', 'config')
268+
self.repl.config.config_path = config_path
269+
self.repl.edit_config()
270+
self.assertTrue(os.path.exists(config_path))
271+
finally:
272+
shutil.rmtree(tmp_dir)
273+
self.assertFalse(os.path.exists(config_path))
274+
275+
255276
class TestRepl(unittest.TestCase):
256277

257278
def set_input_line(self, line):

0 commit comments

Comments
 (0)