1
1
import unittest
2
2
import sys
3
+ import os
3
4
py3 = (sys .version_info [0 ] == 3 )
4
5
5
6
from bpython .curtsiesfrontend import repl
7
+ from bpython import config
8
+
9
+ def setup_config (conf ):
10
+ config_struct = config .Struct ()
11
+ config .loadini (config_struct , os .devnull )
12
+ for key , value in conf .items ():
13
+ if not hasattr (config_struct , key ):
14
+ raise ValueError ("%r is not a valid config attribute" , (key ,))
15
+ setattr (config_struct , key , value )
16
+ return config_struct
6
17
7
18
class TestCurtsiesRepl (unittest .TestCase ):
8
19
9
20
def setUp (self ):
10
- self .repl = repl .Repl ()
21
+ self .config = setup_config ({'editor' :'true' })
22
+ self .repl = repl .Repl (config = self .config )
23
+ os .environ ['PAGER' ] = 'true'
24
+ self .repl .width = 50
25
+ self .repl .height = 20
11
26
12
27
def test_buffer_finished_will_parse (self ):
13
28
self .repl .buffer = ['1 + 1' ]
@@ -23,5 +38,11 @@ def test_buffer_finished_will_parse(self):
23
38
self .repl .buffer = ['def foo(x):' , ' return 1' , '' ]
24
39
self .assertTrue (self .repl .buffer_finished_will_parse (), (True , True ))
25
40
41
+ def test_external_communication (self ):
42
+ self .assertEqual (type (self .repl .version_help_text ()), type (b'' ))
43
+ self .repl .send_current_block_to_external_editor ()
44
+ self .repl .send_session_to_external_editor ()
45
+
46
+
26
47
if __name__ == '__main__' :
27
48
unittest .main ()
0 commit comments