Shortened urlincdec tests to one and some styling
This commit is contained in:
parent
1ecccc1133
commit
4ad2d63c8a
@ -527,8 +527,8 @@ def incdec_number(url, incdec, segments=None):
|
|||||||
if zeroes:
|
if zeroes:
|
||||||
if len(number) < len(str(val)):
|
if len(number) < len(str(val)):
|
||||||
zeroes = zeroes[1:]
|
zeroes = zeroes[1:]
|
||||||
if len(number) > len(str(val)):
|
elif len(number) > len(str(val)):
|
||||||
zeroes = ''.join([zeroes, '0'])
|
zeroes += '0'
|
||||||
|
|
||||||
new_value = ''.join([pre, zeroes, str(val), post])
|
new_value = ''.join([pre, zeroes, str(val), post])
|
||||||
setter(new_value)
|
setter(new_value)
|
||||||
|
@ -586,32 +586,21 @@ class TestIncDecNumber:
|
|||||||
base_url, incdec, segments={'host', 'path', 'query', 'anchor'})
|
base_url, incdec, segments={'host', 'path', 'query', 'anchor'})
|
||||||
assert new_url == expected_url
|
assert new_url == expected_url
|
||||||
|
|
||||||
@pytest.mark.parametrize('number, expected', [
|
@pytest.mark.parametrize('number, expected, incdec', [
|
||||||
('01', '02'),
|
('01', '02', 'increment'),
|
||||||
('09', '10'),
|
('09', '10', 'increment'),
|
||||||
('009', '010')
|
('009', '010', 'increment'),
|
||||||
])
|
('02', '01', 'decrement'),
|
||||||
def test_increment_leading_zeroes(self, number, expected):
|
('10', '9', 'decrement'),
|
||||||
|
('010', '009', 'decrement')
|
||||||
|
])
|
||||||
|
def test_incdec_leading_zeroes(self, number, expected, incdec):
|
||||||
"""Test incdec_number with leading zeroes."""
|
"""Test incdec_number with leading zeroes."""
|
||||||
url = 'http://example.com/{}'
|
url = 'http://example.com/{}'
|
||||||
base_url = QUrl(url.format(number))
|
base_url = QUrl(url.format(number))
|
||||||
expected_url = QUrl(url.format(expected))
|
expected_url = QUrl(url.format(expected))
|
||||||
new_url = urlutils.incdec_number(
|
new_url = urlutils.incdec_number(
|
||||||
base_url, 'increment', segments={'path'})
|
base_url, incdec, segments={'path'})
|
||||||
assert new_url == expected_url
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('number, expected', [
|
|
||||||
('02', '01'),
|
|
||||||
('10', '9'),
|
|
||||||
('010', '009')
|
|
||||||
])
|
|
||||||
def test_decrement_leading_zeroes(self, number, expected):
|
|
||||||
"""Test incdec_number with leading zeroes."""
|
|
||||||
url = 'http://example.com/{}'
|
|
||||||
base_url = QUrl(url.format(number))
|
|
||||||
expected_url = QUrl(url.format(expected))
|
|
||||||
new_url = urlutils.incdec_number(
|
|
||||||
base_url, 'decrement', segments={'path'})
|
|
||||||
assert new_url == expected_url
|
assert new_url == expected_url
|
||||||
|
|
||||||
@pytest.mark.parametrize('url, segments, expected', [
|
@pytest.mark.parametrize('url, segments, expected', [
|
||||||
|
Loading…
Reference in New Issue
Block a user