1
1
import unittest
2
+ import os
3
+ from unittest .mock import patch
2
4
3
5
from _colorize import ANSIColors , get_theme
4
6
from _pyrepl .fancycompleter import Completer , commonprefix
@@ -57,6 +59,7 @@ class C(object):
57
59
compl = Completer ({'a' : None }, use_colors = False )
58
60
self .assertEqual (compl .attr_matches ('a._' ), ['a.__' ])
59
61
62
+ @patch .dict (os .environ , {'PYTHON_COLORS' : '1' })
60
63
def test_complete_attribute_colored (self ):
61
64
theme = get_theme ()
62
65
compl = Completer ({'a' : 42 }, use_colors = True )
@@ -93,6 +96,7 @@ def test_complete_global(self):
93
96
self .assertEqual (compl .global_matches ('foobaz' ), ['foobazzz' ])
94
97
self .assertEqual (compl .global_matches ('nothing' ), [])
95
98
99
+ @patch .dict (os .environ , {'PYTHON_COLORS' : '1' })
96
100
def test_complete_global_colored (self ):
97
101
compl = Completer ({'foobar' : 1 , 'foobazzz' : 2 }, use_colors = True )
98
102
self .assertEqual (compl .global_matches ('foo' ), ['fooba' ])
@@ -111,6 +115,7 @@ def test_complete_global_colored(self):
111
115
self .assertEqual (compl .global_matches ('foobaz' ), ['foobazzz' ])
112
116
self .assertEqual (compl .global_matches ('nothing' ), [])
113
117
118
+ @patch .dict (os .environ , {'PYTHON_COLORS' : '1' })
114
119
def test_complete_global_colored_exception (self ):
115
120
compl = Completer ({'tryme' : 42 }, use_colors = True )
116
121
N0 = f"\x1b [000;00m"
0 commit comments