11import unittest
22import sys
3+ import os
34py3 = (sys .version_info [0 ] == 3 )
45
56from 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
617
718class TestCurtsiesRepl (unittest .TestCase ):
819
920 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
1126
1227 def test_buffer_finished_will_parse (self ):
1328 self .repl .buffer = ['1 + 1' ]
@@ -23,5 +38,11 @@ def test_buffer_finished_will_parse(self):
2338 self .repl .buffer = ['def foo(x):' , ' return 1' , '' ]
2439 self .assertTrue (self .repl .buffer_finished_will_parse (), (True , True ))
2540
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+
2647if __name__ == '__main__' :
2748 unittest .main ()
0 commit comments