From c809276020afcd351f8db27911fe07be98bd4914 Mon Sep 17 00:00:00 2001 From: Sebastian Bank Date: Wed, 15 Dec 2021 22:09:14 +0100 Subject: [PATCH] reformat paremetrize args --- tests/test_formats.py | 60 ++++++++++++++++++++----------------- tests/test_lattices.py | 34 ++++++++++----------- tests/test_serialization.py | 19 ++++++------ 3 files changed, 59 insertions(+), 54 deletions(-) diff --git a/tests/test_formats.py b/tests/test_formats.py index 188552c..175fa14 100644 --- a/tests/test_formats.py +++ b/tests/test_formats.py @@ -7,12 +7,12 @@ from conftest import TEST_OUTPUT -@pytest.mark.parametrize('name, expected', [ - ('table', formats.Table), - ('cxt', formats.Cxt), - ('csv', formats.Csv), - ('wiki-table', formats.WikiTable), -]) +@pytest.mark.parametrize( + 'name, expected', + [('table', formats.Table), + ('cxt', formats.Cxt), + ('csv', formats.Csv), + ('wiki-table', formats.WikiTable)]) def test_getitem(name, expected): assert formats.Format[name] is expected is formats.Format[name.upper()] @@ -22,11 +22,11 @@ def test_getitem_invalid(): formats.Format['spam'] -@pytest.mark.parametrize('filename, expected', [ - ('spam.TXT', 'table'), - ('spam.cxt', 'cxt'), - ('spam.spam.csv', 'csv') -]) +@pytest.mark.parametrize( + 'filename, expected', + [('spam.TXT', 'table'), + ('spam.cxt', 'cxt'), + ('spam.spam.csv', 'csv')]) def test_infer_format(filename, expected): assert formats.Format.infer_format(filename) == expected @@ -171,13 +171,14 @@ class TestCsvUnicode(unittest.TestCase, Unicode): ''' -@pytest.mark.parametrize('source, kwargs', [ - ('''\ +@pytest.mark.parametrize( + 'source, kwargs', + [('''\ cheese,in_stock,sold_out\r Cheddar,0,1\r Limburger,0,1\r ''', {}), - ('''\ + ('''\ cheese,in_stock,sold_out\r Cheddar,,X\r Limburger,,X\r @@ -190,13 +191,14 @@ def test_csv_loads_auto_as_int(source, kwargs): assert args.bools == [(False, True), (False, True)] -@pytest.mark.parametrize('source, expected, match', [ - ('''\ +@pytest.mark.parametrize( + 'source, expected, match', + [('''\ cheese,in_stock,sold_out\r Cheddar,0,\r Limburger,0,1\r ''', ValueError, r"first row: \['Cheddar', '0', ''\]"), - ('''\ + ('''\ cheese,in_stock,sold_out\r Cheddar,0,1\r Limburger,X,1\r @@ -269,8 +271,9 @@ class TestFimi(unittest.TestCase, Ascii): ''' -@pytest.mark.parametrize('frmat, label, kwargs, expected', [ - ('table', None, {}, '''\ +@pytest.mark.parametrize( + 'frmat, label, kwargs, expected', + [('table', None, {}, '''\ |+1|-1|+2|-2|+3|-3|+sg|+pl|-sg|-pl| 1sg|X | | |X | |X |X | | |X | 1pl|X | | |X | |X | |X |X | | @@ -279,7 +282,7 @@ class TestFimi(unittest.TestCase, Ascii): 3sg| |X | |X |X | |X | | |X | 3pl| |X | |X |X | | |X |X | | '''), - ('cxt', None, {}, '''\ + ('cxt', None, {}, '''\ B 6 @@ -308,7 +311,7 @@ class TestFimi(unittest.TestCase, Ascii): .X.XX.X..X .X.XX..XX. '''), - ('python-literal', 'literal', {}, '''\ + ('python-literal', 'literal', {}, '''\ { 'objects': ( '1sg', '1pl', '2sg', '2pl', '3sg', '3pl', @@ -326,7 +329,7 @@ class TestFimi(unittest.TestCase, Ascii): ], } '''), - ('csv', 'str', {'bools_as_int': False}, '''\ + ('csv', 'str', {'bools_as_int': False}, '''\ ,+1,-1,+2,-2,+3,-3,+sg,+pl,-sg,-pl 1sg,X,,,X,,X,X,,,X 1pl,X,,,X,,X,,X,X, @@ -335,7 +338,7 @@ class TestFimi(unittest.TestCase, Ascii): 3sg,,X,,X,X,,X,,,X 3pl,,X,,X,X,,,X,X, '''), - ('csv', 'int', {'bools_as_int': True}, '''\ + ('csv', 'int', {'bools_as_int': True}, '''\ ,+1,-1,+2,-2,+3,-3,+sg,+pl,-sg,-pl 1sg,1,0,0,1,0,1,1,0,0,1 1pl,1,0,0,1,0,1,0,1,1,0 @@ -344,7 +347,7 @@ class TestFimi(unittest.TestCase, Ascii): 3sg,0,1,0,1,1,0,1,0,0,1 3pl,0,1,0,1,1,0,0,1,1,0 '''), - ('fimi', None, {}, '''\ + ('fimi', None, {}, '''\ 0 3 5 6 9 0 3 5 7 8 1 2 5 6 9 @@ -352,7 +355,7 @@ class TestFimi(unittest.TestCase, Ascii): 1 3 4 6 9 1 3 4 7 8 '''), - ('wiki-table', 'wiki-table', {}, '''\ + ('wiki-table', 'wiki-table', {}, '''\ {| class="featuresystem" ! !+1!!-1!!+2!!-2!!+3!!-3!!+sg!!+pl!!-sg!!-pl @@ -409,8 +412,9 @@ def write_format(target, objects, properties, bools, *, Format, **kwargs): return result -@pytest.mark.parametrize('extents, label, expected', [ - (False, 'intents', '''\ +@pytest.mark.parametrize( + 'extents, label, expected', + [(False, 'intents', '''\ 0 1 2 3 4 5 6 7 8 9 0 3 5 6 9 0 3 5 7 8 @@ -434,7 +438,7 @@ def write_format(target, objects, properties, bools, *, Format, **kwargs): 1 '''), - (True, 'extents', '''\ + (True, 'extents', '''\ 0 1 diff --git a/tests/test_lattices.py b/tests/test_lattices.py index 85dc66b..a0d4c85 100644 --- a/tests/test_lattices.py +++ b/tests/test_lattices.py @@ -86,34 +86,34 @@ def test_len(lattice): assert len(lattice) == 22 -@pytest.mark.parametrize('concepts, expected', [ - ([('+1',), ('+2',)], [('+1',), ('+2',), - ('-3',), ('-2',), ('-1',), - ()]), -]) +@pytest.mark.parametrize( + 'concepts, expected', + [([('+1',), ('+2',)], [('+1',), ('+2',), + ('-3',), ('-2',), ('-1',), + ()])]) def test_upset_union(lattice, concepts, expected): concepts, expected = ([lattice[a] for a in arg] for arg in (concepts, expected)) assert list(lattice.upset_union(concepts)) == expected -@pytest.mark.parametrize('concepts, expected', [ - ([('+1',), ('+2',)], [('+1',), ('+2',), - ('+1', '+sg'), ('+1', '+pl'), - ('+2', '+sg'), ('+2', '+pl'), - ('+1', '-1', '+2', '-2', '+3', '-3', '+sg', '+pl', '-sg', '-pl')]), -]) +@pytest.mark.parametrize( + 'concepts, expected', + [([('+1',), ('+2',)], [('+1',), ('+2',), + ('+1', '+sg'), ('+1', '+pl'), + ('+2', '+sg'), ('+2', '+pl'), + ('+1', '-1', '+2', '-2', '+3', '-3', '+sg', '+pl', '-sg', '-pl')])]) def test_downset_union(lattice, concepts, expected): concepts, expected = ([lattice[a] for a in arg] for arg in (concepts, expected)) assert list(lattice.downset_union(concepts)) == expected -@pytest.mark.parametrize('concepts, expected', [ - ([('+1', '+sg'), ('+2', '+sg'), ('+3', '+sg')], - [('+1', '+sg'), ('+2', '+sg'), ('+3', '+sg'), - ('-3', '+sg'), ('-2', '+sg'), ('-1', '+sg'), - ('+sg',)]), -]) +@pytest.mark.parametrize( + 'concepts, expected', + [([('+1', '+sg'), ('+2', '+sg'), ('+3', '+sg')], + [('+1', '+sg'), ('+2', '+sg'), ('+3', '+sg'), + ('-3', '+sg'), ('-2', '+sg'), ('-1', '+sg'), + ('+sg',)])]) def test_upset_generalization(lattice, concepts, expected): concepts, expected = ([lattice[a] for a in arg] for arg in (concepts, expected)) diff --git a/tests/test_serialization.py b/tests/test_serialization.py index 6261610..600a108 100644 --- a/tests/test_serialization.py +++ b/tests/test_serialization.py @@ -53,12 +53,12 @@ 'context': list(SERIALIZED['context'])} -@pytest.mark.parametrize('source, filename, includes_lattice', [ - (repr(SERIALIZED), None, True), - (repr(SERIALIZED_NOLATTICE), None, False), - (repr(SERIALIZED), 'example-serialized-lattice.py', True), - (repr(SERIALIZED_NOLATTICE), 'example-serialized-lattice.py', False), -]) +@pytest.mark.parametrize( + 'source, filename, includes_lattice', + [(repr(SERIALIZED), None, True), + (repr(SERIALIZED_NOLATTICE), None, False), + (repr(SERIALIZED), 'example-serialized-lattice.py', True), + (repr(SERIALIZED_NOLATTICE), 'example-serialized-lattice.py', False)]) def test_fromstring_serialized(tmp_path, source, filename, includes_lattice): if filename is None: context = Context.fromstring(source, frmat='python-literal') @@ -248,8 +248,9 @@ def test_dict_roundtrip(context, ignore_lattice): @pytest.mark.parametrize('to_file', [False, True]) -@pytest.mark.parametrize('with_lattice, expected_doc, expected_str', [ - (False, SERIALIZED_NOLATTICE, +@pytest.mark.parametrize( + 'with_lattice, expected_doc, expected_str', + [(False, SERIALIZED_NOLATTICE, '''\ { 'objects': ( @@ -268,7 +269,7 @@ def test_dict_roundtrip(context, ignore_lattice): ], } '''), - (True, SERIALIZED, + (True, SERIALIZED, '''\ { 'objects': (