@@ -65,6 +65,18 @@ def assert_paint_ignoring_formatting(
65
65
if cursor_row_col is not None :
66
66
self .assertEqual (cursor_pos , cursor_row_col )
67
67
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
+
68
80
69
81
class TestCurtsiesPaintingTest (CurtsiesPaintingTest ):
70
82
def test_history_is_cleared (self ):
@@ -108,22 +120,15 @@ def test_completion(self):
108
120
self .repl .height , self .repl .width = (5 , 32 )
109
121
self .repl .current_line = "an"
110
122
self .cursor_offset = 2
111
- if config . supports_box_chars ():
112
- screen = [
123
+ screen = self . process_box_characters (
124
+ [
113
125
">>> an" ,
114
126
"┌──────────────────────────────┐" ,
115
127
"│ and any( │" ,
116
128
"└──────────────────────────────┘" ,
117
129
"Welcome to bpython! Press <F1> f" ,
118
130
]
119
- else :
120
- screen = [
121
- ">>> an" ,
122
- "+------------------------------+" ,
123
- "| and any( |" ,
124
- "+------------------------------+" ,
125
- "Welcome to bpython! Press <F1> f" ,
126
- ]
131
+ )
127
132
self .assert_paint_ignoring_formatting (screen , (0 , 4 ))
128
133
129
134
def test_argspec (self ):
@@ -729,14 +734,16 @@ def test_simple(self):
729
734
self .repl .current_line = "abc"
730
735
self .repl .cursor_offset = 3
731
736
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
+ )
740
747
self .assert_paint_ignoring_formatting (screen , (0 , 8 ))
741
748
742
749
def test_fill_screen (self ):
@@ -745,23 +752,25 @@ def test_fill_screen(self):
745
752
self .repl .current_line = "abc"
746
753
self .repl .cursor_offset = 3
747
754
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
+ )
765
774
self .assert_paint_ignoring_formatting (screen , (0 , 8 ))
766
775
767
776
def test_lower_on_screen (self ):
@@ -771,37 +780,41 @@ def test_lower_on_screen(self):
771
780
self .repl .current_line = "abc"
772
781
self .repl .cursor_offset = 3
773
782
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
+ )
791
802
# behavior before issue #466
792
803
self .assert_paint_ignoring_formatting (
793
804
screen , try_preserve_history_height = 0
794
805
)
795
806
self .assert_paint_ignoring_formatting (screen , min_infobox_height = 100 )
796
807
# 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
+ )
805
818
self .assert_paint_ignoring_formatting (screen )
806
819
807
820
def test_at_bottom_of_screen (self ):
@@ -811,35 +824,39 @@ def test_at_bottom_of_screen(self):
811
824
self .repl .current_line = "abc"
812
825
self .repl .cursor_offset = 3
813
826
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
+ )
831
846
# behavior before issue #466
832
847
self .assert_paint_ignoring_formatting (
833
848
screen , try_preserve_history_height = 0
834
849
)
835
850
self .assert_paint_ignoring_formatting (screen , min_infobox_height = 100 )
836
851
# 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
+ )
845
862
self .assert_paint_ignoring_formatting (screen )
0 commit comments