-
-
Notifications
You must be signed in to change notification settings - Fork 102
chore: improve python-progressbar maintenance path #314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,3 +112,57 @@ def raise_error(): | |
|
|
||
| fd.isatty = raise_error | ||
| assert not progressbar.env.is_ansi_terminal(fd) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| 'value,expected', | ||
| [ | ||
| ('', ''), | ||
| (b'', b''), | ||
| ('\x1b[31m', ''), | ||
| (b'\x1b[31m', b''), | ||
| ('\x1b[1m\x1b[31mtext\x1b[0m', 'text'), | ||
| (b'\x1b[1m\x1b[31mtext\x1b[0m', b'text'), | ||
| ('\x1b[38;5;208mhello world\x1b[0m', 'hello world'), | ||
| ], | ||
| ) | ||
| def test_no_color(value, expected) -> None: | ||
| assert progressbar.utils.no_color(value) == expected | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tests use |
||
|
|
||
|
|
||
| def test_no_color_type_error() -> None: | ||
| with pytest.raises(TypeError): | ||
| progressbar.utils.no_color(123) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| 'value,expected', | ||
| [ | ||
| ('', 0), | ||
| (b'', 0), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ('\x1b[31m', 0), | ||
| ('\x1b[1m\x1b[31mtext\x1b[0m', 4), | ||
| ('\x1b[38;5;208mhello world\x1b[0m', 11), | ||
| ], | ||
| ) | ||
| def test_len_color(value, expected) -> None: | ||
| assert progressbar.utils.len_color(value) == expected | ||
|
|
||
|
|
||
| def test_attribute_dict_empty() -> None: | ||
| attrs = progressbar.utils.AttributeDict() | ||
| assert len(attrs) == 0 | ||
| with pytest.raises(AttributeError): | ||
| attrs.missing | ||
|
|
||
|
|
||
| def test_attribute_dict_set_get_del() -> None: | ||
| attrs = progressbar.utils.AttributeDict() | ||
| attrs.spam = 123 | ||
| assert attrs['spam'] == 123 | ||
| assert attrs.spam == 123 | ||
| del attrs.spam | ||
| with pytest.raises(AttributeError): | ||
| attrs.spam | ||
| with pytest.raises(AttributeError): | ||
| del attrs.spam | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a test case for 24-bit (TrueColor) ANSI sequences to ensure they are also correctly stripped by
no_color.