Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion colorama/ansitowin32.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ def convert_osc(self, text):
# 1 - change icon (we don't support this)
# 2 - change title
if params[0] in '02':
winterm.set_title(params[1])
if self.convert and winterm:
winterm.set_title(params[1])
return text


Expand Down
7 changes: 7 additions & 0 deletions colorama/tests/ansitowin32_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,13 @@ def test_osc_codes(self):
stream.write(code)
self.assertEqual(winterm.set_title.call_count, 2)

@patch('colorama.ansitowin32.winterm', None)
def test_osc_codes_without_winterm(self):
mockStdout = Mock()
stream = AnsiToWin32(mockStdout, convert=False, strip=True)
stream.write('\033]0;test title\x07')
stream.write('\033]2;test title\x07')

def test_native_windows_ansi(self):
with ExitStack() as stack:
def p(a, b):
Expand Down