@@ -65,6 +65,18 @@ def assert_paint_ignoring_formatting(
6565 if cursor_row_col is not None :
6666 self .assertEqual (cursor_pos , cursor_row_col )
6767
68+ def process_box_characters (self , screen ):
69+ if not self .repl .config .unicode_box or not config .supports_box_chars ():
70+ return [
71+ line .replace ("┌" , "+" )
72+ .replace ("└" , "+" )
73+ .replace ("┘" , "+" )
74+ .replace ("┐" , "+" )
75+ .replace ("─" , "-" )
76+ for line in screen
77+ ]
78+ return screen
79+
6880
6981class TestCurtsiesPaintingTest (CurtsiesPaintingTest ):
7082 def test_history_is_cleared (self ):
@@ -108,22 +120,15 @@ def test_completion(self):
108120 self .repl .height , self .repl .width = (5 , 32 )
109121 self .repl .current_line = "an"
110122 self .cursor_offset = 2
111- if config . supports_box_chars ():
112- screen = [
123+ screen = self . process_box_characters (
124+ [
113125 ">>> an" ,
114126 "┌──────────────────────────────┐" ,
115127 "│ and any( │" ,
116128 "└──────────────────────────────┘" ,
117129 "Welcome to bpython! Press <F1> f" ,
118130 ]
119- else :
120- screen = [
121- ">>> an" ,
122- "+------------------------------+" ,
123- "| and any( |" ,
124- "+------------------------------+" ,
125- "Welcome to bpython! Press <F1> f" ,
126- ]
131+ )
127132 self .assert_paint_ignoring_formatting (screen , (0 , 4 ))
128133
129134 def test_argspec (self ):
@@ -729,14 +734,16 @@ def test_simple(self):
729734 self .repl .current_line = "abc"
730735 self .repl .cursor_offset = 3
731736 self .repl .process_event ("." )
732- screen = [
733- ">>> abc." ,
734- "+------------------+" ,
735- "| aaaaaaaaaaaaaaaa |" ,
736- "| b |" ,
737- "| c |" ,
738- "+------------------+" ,
739- ]
737+ screen = self .process_box_characters (
738+ [
739+ ">>> abc." ,
740+ "┌──────────────────┐" ,
741+ "│ aaaaaaaaaaaaaaaa │" ,
742+ "│ b │" ,
743+ "│ c │" ,
744+ "└──────────────────┘" ,
745+ ]
746+ )
740747 self .assert_paint_ignoring_formatting (screen , (0 , 8 ))
741748
742749 def test_fill_screen (self ):
@@ -745,23 +752,25 @@ def test_fill_screen(self):
745752 self .repl .current_line = "abc"
746753 self .repl .cursor_offset = 3
747754 self .repl .process_event ("." )
748- screen = [
749- ">>> abc." ,
750- "+------------------+" ,
751- "| aaaaaaaaaaaaaaaa |" ,
752- "| b |" ,
753- "| c |" ,
754- "| d |" ,
755- "| e |" ,
756- "| f |" ,
757- "| g |" ,
758- "| h |" ,
759- "| i |" ,
760- "| j |" ,
761- "| k |" ,
762- "| l |" ,
763- "+------------------+" ,
764- ]
755+ screen = self .process_box_characters (
756+ [
757+ ">>> abc." ,
758+ "┌──────────────────┐" ,
759+ "│ aaaaaaaaaaaaaaaa │" ,
760+ "│ b │" ,
761+ "│ c │" ,
762+ "│ d │" ,
763+ "│ e │" ,
764+ "│ f │" ,
765+ "│ g │" ,
766+ "│ h │" ,
767+ "│ i │" ,
768+ "│ j │" ,
769+ "│ k │" ,
770+ "│ l │" ,
771+ "└──────────────────┘" ,
772+ ]
773+ )
765774 self .assert_paint_ignoring_formatting (screen , (0 , 8 ))
766775
767776 def test_lower_on_screen (self ):
@@ -771,37 +780,41 @@ def test_lower_on_screen(self):
771780 self .repl .current_line = "abc"
772781 self .repl .cursor_offset = 3
773782 self .repl .process_event ("." )
774- screen = [
775- ">>> abc." ,
776- "+------------------+" ,
777- "| aaaaaaaaaaaaaaaa |" ,
778- "| b |" ,
779- "| c |" ,
780- "| d |" ,
781- "| e |" ,
782- "| f |" ,
783- "| g |" ,
784- "| h |" ,
785- "| i |" ,
786- "| j |" ,
787- "| k |" ,
788- "| l |" ,
789- "+------------------+" ,
790- ]
783+ screen = self .process_box_characters (
784+ [
785+ ">>> abc." ,
786+ "┌──────────────────┐" ,
787+ "│ aaaaaaaaaaaaaaaa │" ,
788+ "│ b │" ,
789+ "│ c │" ,
790+ "│ d │" ,
791+ "│ e │" ,
792+ "│ f │" ,
793+ "│ g │" ,
794+ "│ h │" ,
795+ "│ i │" ,
796+ "│ j │" ,
797+ "│ k │" ,
798+ "│ l │" ,
799+ "└──────────────────┘" ,
800+ ]
801+ )
791802 # behavior before issue #466
792803 self .assert_paint_ignoring_formatting (
793804 screen , try_preserve_history_height = 0
794805 )
795806 self .assert_paint_ignoring_formatting (screen , min_infobox_height = 100 )
796807 # behavior after issue #466
797- screen = [
798- ">>> abc." ,
799- "+------------------+" ,
800- "| aaaaaaaaaaaaaaaa |" ,
801- "| b |" ,
802- "| c |" ,
803- "+------------------+" ,
804- ]
808+ screen = self .process_box_characters (
809+ [
810+ ">>> abc." ,
811+ "┌──────────────────┐" ,
812+ "│ aaaaaaaaaaaaaaaa │" ,
813+ "│ b │" ,
814+ "│ c │" ,
815+ "└──────────────────┘" ,
816+ ]
817+ )
805818 self .assert_paint_ignoring_formatting (screen )
806819
807820 def test_at_bottom_of_screen (self ):
@@ -811,35 +824,39 @@ def test_at_bottom_of_screen(self):
811824 self .repl .current_line = "abc"
812825 self .repl .cursor_offset = 3
813826 self .repl .process_event ("." )
814- screen = [
815- ">>> abc." ,
816- "+------------------+" ,
817- "| aaaaaaaaaaaaaaaa |" ,
818- "| b |" ,
819- "| c |" ,
820- "| d |" ,
821- "| e |" ,
822- "| f |" ,
823- "| g |" ,
824- "| h |" ,
825- "| i |" ,
826- "| j |" ,
827- "| k |" ,
828- "| l |" ,
829- "+------------------+" ,
830- ]
827+ screen = self .process_box_characters (
828+ [
829+ ">>> abc." ,
830+ "┌──────────────────┐" ,
831+ "│ aaaaaaaaaaaaaaaa │" ,
832+ "│ b │" ,
833+ "│ c │" ,
834+ "│ d │" ,
835+ "│ e │" ,
836+ "│ f │" ,
837+ "│ g │" ,
838+ "│ h │" ,
839+ "│ i │" ,
840+ "│ j │" ,
841+ "│ k │" ,
842+ "│ l │" ,
843+ "└──────────────────┘" ,
844+ ]
845+ )
831846 # behavior before issue #466
832847 self .assert_paint_ignoring_formatting (
833848 screen , try_preserve_history_height = 0
834849 )
835850 self .assert_paint_ignoring_formatting (screen , min_infobox_height = 100 )
836851 # behavior after issue #466
837- screen = [
838- ">>> abc." ,
839- "+------------------+" ,
840- "| aaaaaaaaaaaaaaaa |" ,
841- "| b |" ,
842- "| c |" ,
843- "+------------------+" ,
844- ]
852+ screen = self .process_box_characters (
853+ [
854+ ">>> abc." ,
855+ "┌──────────────────┐" ,
856+ "│ aaaaaaaaaaaaaaaa │" ,
857+ "│ b │" ,
858+ "│ c │" ,
859+ "└──────────────────┘" ,
860+ ]
861+ )
845862 self .assert_paint_ignoring_formatting (screen )
0 commit comments