diff options
Diffstat (limited to 'tests/test_decoders.py')
-rwxr-xr-x | tests/test_decoders.py | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/tests/test_decoders.py b/tests/test_decoders.py index 785ba32..e3423aa 100755 --- a/tests/test_decoders.py +++ b/tests/test_decoders.py @@ -3,19 +3,20 @@ # Copyright (C) 2019-2021 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr> # This file is part of the thcolor project, which is MIT-licensed. # ***************************************************************************** -""" Unit tests for the thcolor color decoding and management module. """ +"""Unit tests for the thcolor color decoding and management module.""" from typing import Any import pytest -from thcolor.angles import * # NOQA -from thcolor.colors import * # NOQA -from thcolor.decoders import * # NOQA -from thcolor.errors import * # NOQA + +from thcolor.angles import * +from thcolor.colors import * +from thcolor.decoders import * +from thcolor.errors import * class TestInvalidDecoders: - """ Test the exceptions raised when an invalid decoder is created. """ + """Test the exceptions raised when an invalid decoder is created.""" def test_unknown_data_type(self): with pytest.raises(TypeError, match=r'neither an alias'): @@ -52,7 +53,7 @@ class TestInvalidDecoders: class TestBaseDecoder: - """ Test the base decoder with no options enabled. """ + """Test the base decoder with no options enabled.""" @pytest.fixture def decoder(self): @@ -74,9 +75,9 @@ class TestBaseDecoder: )), )) def test_syntax(self, decoder, test_input, expected): - """ Test basic syntax. + """Test basic syntax. - Tests syntaxes that are always available, with separators. + Tests syntaxes that are always available, with separators. """ result = decoder.decode(test_input) @@ -88,47 +89,47 @@ class TestBaseDecoder: )), )) def test_coersce_into_angles(self, decoder, test_input, expected): - """ Test the decoding while indicating that we want angles. """ + """Test the decoding while indicating that we want angles.""" result = decoder.decode(test_input, prefer_angles=True) assert result == expected def test_existing_variable(self, decoder): - """ Test getting an existing variable. """ + """Test getting an existing variable.""" result = decoder.decode('hello') assert result == (56.78,) def test_non_existing_variable(self, decoder): - """ Test getting a non-existing variable. """ + """Test getting a non-existing variable.""" with pytest.raises(ColorExpressionSyntaxError, match=r'unknown value'): decoder.decode('nonexisting') def test_existing_variable_ncol_format(self, decoder): - """ Test decoding an expression using an NCol-like variable. + """Test decoding an expression using an NCol-like variable. - We want to avoid the NCol subsytem from shadowing - existing variables when NCol support is disabled. + We want to avoid the NCol subsytem from shadowing + existing variables when NCol support is disabled. """ result = decoder.decode('B20') assert result == (12.34,) def test_non_existing_variable_ncol_format(self, decoder): - """ Test decoding an expression using an NCol-like variable. + """Test decoding an expression using an NCol-like variable. - We want to avoid the NCol subsystem intercepting errors - in case of non-existing variables. + We want to avoid the NCol subsystem intercepting errors + in case of non-existing variables. """ with pytest.raises(ColorExpressionSyntaxError, match=r'unknown value'): decoder.decode('Y40') def test_disabled_extended_hex(self, decoder): - """ Test decoding an expression using an extended hex color. + """Test decoding an expression using an extended hex color. - This should be disabled in this state. + This should be disabled in this state. """ with pytest.raises(ColorExpressionSyntaxError, match=r'extended hex'): @@ -136,7 +137,7 @@ class TestBaseDecoder: class TestExtendedHexDecoder: - """ Test base decoder with extended hex support. """ + """Test base decoder with extended hex support.""" @pytest.fixture def decoder(self): @@ -154,7 +155,7 @@ class TestExtendedHexDecoder: class TestNColDecoder: - """ Test base decoder with ncol support. """ + """Test base decoder with ncol support.""" @pytest.fixture def decoder(self): @@ -203,7 +204,7 @@ class TestNColDecoder: ), )) def test_ncol(self, decoder, test_input, expected): - """ Test natural colors. """ + """Test natural colors.""" result = decoder.decode(test_input) assert result == (expected,) @@ -214,7 +215,7 @@ class TestNColDecoder: class TestNetscapeDecoder: - """ Test base decoder with netscape color support. """ + """Test base decoder with netscape color support.""" @pytest.fixture def decoder(self): @@ -232,7 +233,7 @@ class TestNetscapeDecoder: ), )) def test_netscape_colors(self, decoder, test_input, expected): - """ Test decoding using Netscape colors. """ + """Test decoding using Netscape colors.""" result = decoder.decode(test_input, prefer_colors=True) assert result == (expected,) @@ -243,10 +244,10 @@ class TestNetscapeDecoder: ('123.0', SRGBColor.frombytes(18, 48, 0, 1.00)), )) def test_coersce_into_colors(self, decoder, test_input, expected): - """ Test the decoding while indicating that we want colors. + """Test the decoding while indicating that we want colors. - It is expected from the decoder to use Netscape color name - style decoding in this scenario. + It is expected from the decoder to use Netscape color name + style decoding in this scenario. """ result = decoder.decode(test_input, prefer_colors=True) |