1
1
import unittest
2
2
import os
3
- from unittest .mock import patch
4
3
5
4
from _colorize import ANSIColors , get_theme
6
5
from _pyrepl .fancycompleter import Completer , commonprefix
@@ -59,7 +58,6 @@ class C(object):
59
58
compl = Completer ({'a' : None }, use_colors = False )
60
59
self .assertEqual (compl .attr_matches ('a._' ), ['a.__' ])
61
60
62
- @patch .dict (os .environ , {'PYTHON_COLORS' : '1' })
63
61
def test_complete_attribute_colored (self ):
64
62
theme = get_theme ()
65
63
compl = Completer ({'a' : 42 }, use_colors = True )
@@ -96,8 +94,8 @@ def test_complete_global(self):
96
94
self .assertEqual (compl .global_matches ('foobaz' ), ['foobazzz' ])
97
95
self .assertEqual (compl .global_matches ('nothing' ), [])
98
96
99
- @patch .dict (os .environ , {'PYTHON_COLORS' : '1' })
100
97
def test_complete_global_colored (self ):
98
+ theme = get_theme ()
101
99
compl = Completer ({'foobar' : 1 , 'foobazzz' : 2 }, use_colors = True )
102
100
self .assertEqual (compl .global_matches ('foo' ), ['fooba' ])
103
101
matches = compl .global_matches ('fooba' )
@@ -106,26 +104,15 @@ def test_complete_global_colored(self):
106
104
# readline displays the matches in the proper order
107
105
N0 = f"\x1b [000;00m"
108
106
N1 = f"\x1b [001;00m"
109
-
107
+ int_color = theme . fancycompleter . int
110
108
self .assertEqual (set (matches ), {
111
109
' ' ,
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 } ' ,
114
112
})
115
113
self .assertEqual (compl .global_matches ('foobaz' ), ['foobazzz' ])
116
114
self .assertEqual (compl .global_matches ('nothing' ), [])
117
115
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
-
129
116
def test_complete_with_indexer (self ):
130
117
compl = Completer ({'lst' : [None , 2 , 3 ]}, use_colors = False )
131
118
self .assertEqual (compl .attr_matches ('lst[0].' ), ['lst[0].__' ])
0 commit comments