From 9a16b73f48320422de3115a2e3532e614cfc69f1 Mon Sep 17 00:00:00 2001 From: Rick van Hattem Date: Thu, 25 Jan 2024 03:49:22 +0100 Subject: [PATCH] Fixing windows test issues --- tests/test_color.py | 8 +++++--- tests/test_stream.py | 2 ++ tests/test_utils.py | 6 +++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/test_color.py b/tests/test_color.py index 1a6657e..bf76eec 100644 --- a/tests/test_color.py +++ b/tests/test_color.py @@ -1,5 +1,6 @@ from __future__ import annotations +import os import typing import progressbar @@ -183,9 +184,10 @@ def test_colors(): def test_color(): color = colors.red - assert color('x') == color.fg('x') != 'x' - assert color.fg('x') != color.bg('x') != 'x' - assert color.fg('x') != color.underline('x') != 'x' + if os.name != 'nt': + assert color('x') == color.fg('x') != 'x' + assert color.fg('x') != color.bg('x') != 'x' + assert color.fg('x') != color.underline('x') != 'x' # Color hashes are based on the RGB value assert hash(color) == hash(terminal.Color(color.rgb, None, None, None)) Colors.register(color.rgb) diff --git a/tests/test_stream.py b/tests/test_stream.py index c92edf7..1803ffd 100644 --- a/tests/test_stream.py +++ b/tests/test_stream.py @@ -1,4 +1,5 @@ import io +import os import sys import progressbar @@ -98,6 +99,7 @@ def test_no_newlines(): @pytest.mark.parametrize('stream', [sys.__stdout__, sys.__stderr__]) +@pytest.mark.skipif(os.name == 'nt', reason='Windows does not support this') def test_fd_as_standard_streams(stream): with progressbar.ProgressBar(fd=stream) as pb: for i in range(101): diff --git a/tests/test_utils.py b/tests/test_utils.py index 34bd0da..c9d9531 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,4 +1,5 @@ import io +import os import progressbar import progressbar.env @@ -107,4 +108,7 @@ def test_is_ansi_terminal(monkeypatch): def raise_error(): raise RuntimeError('test') fd.isatty = raise_error - assert progressbar.env.is_ansi_terminal(fd) is False + if os.name == 'nt': + assert progressbar.env.is_ansi_terminal(fd) is None + else: + assert progressbar.env.is_ansi_terminal(fd) is False