Skip to content

Commit

Permalink
Add test for None in sequences
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiburt committed Nov 6, 2021
1 parent 67ab23d commit d7eb3ee
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/test_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,35 @@ def test_varied_list():
)
def test_none_map_value(input_obj, output_toml):
assert rtoml.dumps(input_obj) == output_toml

@pytest.mark.parametrize(
'input_obj,output_toml',
[
([None], '[]'),
(["a", None], '["a"]'),
([None, "b"], '["b"]'),
(["a", None, "b"], '["a", "b"]'),
({'foo': 'bar', 'list': [None]}, 'foo = "bar"\nlist = []\n'),
({'foo': 'bar', 'list': [None, "b"]}, 'foo = "bar"\nlist = ["b"]\n'),
({'foo': 'bar', 'list': ["a", None]}, 'foo = "bar"\nlist = ["a"]\n'),
({'foo': 'bar', 'list': ["a", None, "b"]}, 'foo = "bar"\nlist = ["a", "b"]\n'),
],
)
def test_none_values_inside_list(input_obj, output_toml):
assert rtoml.dumps(input_obj) == output_toml

@pytest.mark.parametrize(
'input_obj,output_toml',
[
((None), '"null"'),
(("a", None), '["a"]'),
((None, "b"), '["b"]'),
(("a", None, "b"), '["a", "b"]'),
({'foo': 'bar', 'list': (None)}, 'foo = "bar"\n'),
({'foo': 'bar', 'list': (None, "b")}, 'foo = "bar"\nlist = ["b"]\n'),
({'foo': 'bar', 'list': ("a", None)}, 'foo = "bar"\nlist = ["a"]\n'),
({'foo': 'bar', 'list': ("a", None, "b")}, 'foo = "bar"\nlist = ["a", "b"]\n'),
],
)
def test_none_values_inside_tuple(input_obj, output_toml):
assert rtoml.dumps(input_obj) == output_toml

0 comments on commit d7eb3ee

Please sign in to comment.