diff --git a/alternative_encodings/viscii.py b/alternative_encodings/viscii.py index 87952e3..b555061 100644 --- a/alternative_encodings/viscii.py +++ b/alternative_encodings/viscii.py @@ -1,12 +1,6 @@ import codecs -from .common import ( - get_codec, - get_incremental_decoder, - get_incremental_encoder, - get_stream_reader, - get_stream_writer, -) +from .common import get_codec, get_incremental_decoder, get_incremental_encoder, get_stream_reader, get_stream_writer # Decoding Table diff --git a/tests/test_cp859.py b/tests/test_cp859.py index 52ba0e3..48af44a 100644 --- a/tests/test_cp859.py +++ b/tests/test_cp859.py @@ -3,7 +3,7 @@ import pytest from utils import register_codec -import alternative_encodings.cp859 as cp859 +from alternative_encodings import cp859 @pytest.fixture(scope="module", autouse=True) @@ -24,6 +24,12 @@ def register_codec_fixture(): ) -def test_encode(): +@pytest.mark.parametrize("source_data, encoded", + [ + (source_data, encoded), + ('\r\n', b'\r\n'), + ] +) +def test_encode(source_data, encoded): assert codecs.encode(source_data, "cp859") == encoded assert codecs.decode(encoded, "cp859") == source_data diff --git a/tests/test_cp866i.py b/tests/test_cp866i.py index d38e23b..4f4e83b 100644 --- a/tests/test_cp866i.py +++ b/tests/test_cp866i.py @@ -3,7 +3,7 @@ import pytest from utils import register_codec -import alternative_encodings.cp866i as cp866i +from alternative_encodings import cp866i @pytest.fixture(scope="module", autouse=True) diff --git a/tests/test_general.py b/tests/test_general.py new file mode 100644 index 0000000..d5cde09 --- /dev/null +++ b/tests/test_general.py @@ -0,0 +1,25 @@ +import codecs + +import pytest +from utils import register_codec + +from alternative_encodings import cp859, cp866i, viscii + +codecs_pairs = [ + ("cp859", cp859), + ("cp866i", cp866i), + ("viscii", viscii), +] + + +@pytest.mark.parametrize("string", + [ + "\r\n", + ] +) +def test_general(string): + for codec_name, codec in codecs_pairs: + with register_codec(codec): + encoded = codecs.encode(string, encoding=codec_name) + decoded = codecs.decode(encoded, encoding=codec_name) + assert decoded == string diff --git a/tests/test_viscii.py b/tests/test_viscii.py index 1835b4b..10e87cf 100644 --- a/tests/test_viscii.py +++ b/tests/test_viscii.py @@ -3,7 +3,7 @@ import pytest from utils import register_codec -import alternative_encodings.viscii as viscii +from alternative_encodings import viscii @pytest.fixture(scope="module", autouse=True)