Parametrize test_str_split_maxsplit

As suggested by @hackebrot
This commit is contained in:
Bruno Oliveira 2015-04-09 18:44:40 -03:00
parent 253f3b2cd7
commit 6f1e830aba

View File

@ -170,18 +170,12 @@ class TestSimpleSplit:
"""Test if the behavior matches str.split.""" """Test if the behavior matches str.split."""
assert split.simple_split(test) == test.rstrip().split() assert split.simple_split(test) == test.rstrip().split()
def test_str_split_maxsplit_1(self): @pytest.mark.parametrize('s, maxsplit',
"""Test if the behavior matches str.split with maxsplit=1.""" [("foo bar baz", 1), (" foo bar baz ", 0)])
s = "foo bar baz" def test_str_split_maxsplit(self, s, maxsplit):
actual = split.simple_split(s, maxsplit=1) """Test if the behavior matches str.split with given maxsplit."""
expected = s.rstrip().split(maxsplit=1) actual = split.simple_split(s, maxsplit=maxsplit)
assert actual == expected expected = s.rstrip().split(maxsplit=maxsplit)
def test_str_split_maxsplit_0(self):
"""Test if the behavior matches str.split with maxsplit=0."""
s = " foo bar baz "
actual = split.simple_split(s, maxsplit=0)
expected = s.rstrip().split(maxsplit=0)
assert actual == expected assert actual == expected
@pytest.mark.parametrize('test, expected', TESTS.items()) @pytest.mark.parametrize('test, expected', TESTS.items())