11import unittest
22import os
3- from unittest .mock import patch
43
54from _colorize import ANSIColors , get_theme
65from _pyrepl .fancycompleter import Completer , commonprefix
@@ -59,7 +58,6 @@ class C(object):
5958 compl = Completer ({'a' : None }, use_colors = False )
6059 self .assertEqual (compl .attr_matches ('a._' ), ['a.__' ])
6160
62- @patch .dict (os .environ , {'PYTHON_COLORS' : '1' })
6361 def test_complete_attribute_colored (self ):
6462 theme = get_theme ()
6563 compl = Completer ({'a' : 42 }, use_colors = True )
@@ -96,8 +94,8 @@ def test_complete_global(self):
9694 self .assertEqual (compl .global_matches ('foobaz' ), ['foobazzz' ])
9795 self .assertEqual (compl .global_matches ('nothing' ), [])
9896
99- @patch .dict (os .environ , {'PYTHON_COLORS' : '1' })
10097 def test_complete_global_colored (self ):
98+ theme = get_theme ()
10199 compl = Completer ({'foobar' : 1 , 'foobazzz' : 2 }, use_colors = True )
102100 self .assertEqual (compl .global_matches ('foo' ), ['fooba' ])
103101 matches = compl .global_matches ('fooba' )
@@ -106,26 +104,15 @@ def test_complete_global_colored(self):
106104 # readline displays the matches in the proper order
107105 N0 = f"\x1b [000;00m"
108106 N1 = f"\x1b [001;00m"
109-
107+ int_color = theme . fancycompleter . int
110108 self .assertEqual (set (matches ), {
111109 ' ' ,
112- f'{ N0 } { ANSIColors . BOLD_YELLOW } foobar{ ANSIColors .RESET } ' ,
113- f'{ N1 } { ANSIColors . BOLD_YELLOW } foobazzz{ ANSIColors .RESET } ' ,
110+ f'{ N0 } { int_color } foobar{ ANSIColors .RESET } ' ,
111+ f'{ N1 } { int_color } foobazzz{ ANSIColors .RESET } ' ,
114112 })
115113 self .assertEqual (compl .global_matches ('foobaz' ), ['foobazzz' ])
116114 self .assertEqual (compl .global_matches ('nothing' ), [])
117115
118- @patch .dict (os .environ , {'PYTHON_COLORS' : '1' })
119- def test_complete_global_colored_exception (self ):
120- compl = Completer ({'tryme' : 42 }, use_colors = True )
121- N0 = f"\x1b [000;00m"
122- N1 = f"\x1b [001;00m"
123- self .assertEqual (compl .global_matches ('try' ), [
124- f'{ N0 } { ANSIColors .GREY } try:{ ANSIColors .RESET } ' ,
125- f'{ N1 } { ANSIColors .BOLD_YELLOW } tryme{ ANSIColors .RESET } ' ,
126- ' '
127- ])
128-
129116 def test_complete_with_indexer (self ):
130117 compl = Completer ({'lst' : [None , 2 , 3 ]}, use_colors = False )
131118 self .assertEqual (compl .attr_matches ('lst[0].' ), ['lst[0].__' ])
0 commit comments