11import unittest
2+ import os
3+ from unittest .mock import patch
24
35from _colorize import ANSIColors , get_theme
46from _pyrepl .fancycompleter import Completer , commonprefix
@@ -57,6 +59,7 @@ class C(object):
5759 compl = Completer ({'a' : None }, use_colors = False )
5860 self .assertEqual (compl .attr_matches ('a._' ), ['a.__' ])
5961
62+ @patch .dict (os .environ , {'PYTHON_COLORS' : '1' })
6063 def test_complete_attribute_colored (self ):
6164 theme = get_theme ()
6265 compl = Completer ({'a' : 42 }, use_colors = True )
@@ -93,6 +96,7 @@ def test_complete_global(self):
9396 self .assertEqual (compl .global_matches ('foobaz' ), ['foobazzz' ])
9497 self .assertEqual (compl .global_matches ('nothing' ), [])
9598
99+ @patch .dict (os .environ , {'PYTHON_COLORS' : '1' })
96100 def test_complete_global_colored (self ):
97101 compl = Completer ({'foobar' : 1 , 'foobazzz' : 2 }, use_colors = True )
98102 self .assertEqual (compl .global_matches ('foo' ), ['fooba' ])
@@ -111,6 +115,7 @@ def test_complete_global_colored(self):
111115 self .assertEqual (compl .global_matches ('foobaz' ), ['foobazzz' ])
112116 self .assertEqual (compl .global_matches ('nothing' ), [])
113117
118+ @patch .dict (os .environ , {'PYTHON_COLORS' : '1' })
114119 def test_complete_global_colored_exception (self ):
115120 compl = Completer ({'tryme' : 42 }, use_colors = True )
116121 N0 = f"\x1b [000;00m"
0 commit comments