fixup! incdec_number: add support for port
This commit is contained in:
parent
6a40cbf160
commit
9f14ae184f
@ -561,7 +561,7 @@ def incdec_number(url, incdec, count=1, segments=None):
|
|||||||
# Order as they appear in a URL
|
# Order as they appear in a URL
|
||||||
segment_modifiers = [
|
segment_modifiers = [
|
||||||
('host', url.host, url.setHost),
|
('host', url.host, url.setHost),
|
||||||
('port', lambda: str(url.port()), lambda x: url.setPort(int(x))),
|
('port', lambda: str(url.port()) if url.port() > 0 else '', lambda x: url.setPort(int(x))),
|
||||||
('path', url.path, url.setPath),
|
('path', url.path, url.setPath),
|
||||||
('query', url.query, url.setQuery),
|
('query', url.query, url.setQuery),
|
||||||
('anchor', url.fragment, url.setFragment),
|
('anchor', url.fragment, url.setFragment),
|
||||||
|
@ -633,6 +633,12 @@ class TestIncDecNumber:
|
|||||||
base_url, 'decrement', segments={'port'})
|
base_url, 'decrement', segments={'port'})
|
||||||
assert new_url == QUrl('http://localhost:7999')
|
assert new_url == QUrl('http://localhost:7999')
|
||||||
|
|
||||||
|
def test_incdec_port_default(self):
|
||||||
|
"""Test that a default port (with url.port() == -1) is not touched."""
|
||||||
|
base_url = QUrl('http://localhost')
|
||||||
|
with pytest.raises(urlutils.IncDecError):
|
||||||
|
urlutils.incdec_number(base_url, 'increment', segments={'port'})
|
||||||
|
|
||||||
@pytest.mark.parametrize('incdec', ['increment', 'decrement'])
|
@pytest.mark.parametrize('incdec', ['increment', 'decrement'])
|
||||||
@pytest.mark.parametrize('value', [
|
@pytest.mark.parametrize('value', [
|
||||||
'{}foo', 'foo{}', 'foo{}bar', '42foo{}'
|
'{}foo', 'foo{}', 'foo{}bar', '42foo{}'
|
||||||
|
Loading…
Reference in New Issue
Block a user