rename url_incdec_number to incdec_number
This commit is contained in:
parent
276b163e0d
commit
c4c3a83ac0
@ -472,7 +472,7 @@ class CommandDispatcher:
|
|||||||
window: Open the link in a new window.
|
window: Open the link in a new window.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
new_url = urlutils.url_incdec_number(url, incdec)
|
new_url = urlutils.incdec_number(url, incdec)
|
||||||
except urlutils.IncDecError as error:
|
except urlutils.IncDecError as error:
|
||||||
raise cmdexc.CommandError(error.msg)
|
raise cmdexc.CommandError(error.msg)
|
||||||
self._open(new_url, tab, background, window)
|
self._open(new_url, tab, background, window)
|
||||||
|
@ -447,7 +447,7 @@ class FuzzyUrlError(Exception):
|
|||||||
|
|
||||||
class IncDecError(Exception):
|
class IncDecError(Exception):
|
||||||
|
|
||||||
"""Exception raised by url_incdec_number on problems.
|
"""Exception raised by incdec_number on problems.
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
msg: The error message.
|
msg: The error message.
|
||||||
@ -463,7 +463,7 @@ class IncDecError(Exception):
|
|||||||
return '{}: {}'.format(self.msg, self.url.toString())
|
return '{}: {}'.format(self.msg, self.url.toString())
|
||||||
|
|
||||||
|
|
||||||
def url_incdec_number(url, incdec):
|
def incdec_number(url, incdec):
|
||||||
"""Find a number in the url and increment or decrement it.
|
"""Find a number in the url and increment or decrement it.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -536,9 +536,9 @@ def test_same_domain_invalid_url(url1, url2):
|
|||||||
("http://bbc.c0.uk:80/story_1", "decrement", "http://bbc.c0.uk:80/story_0"),
|
("http://bbc.c0.uk:80/story_1", "decrement", "http://bbc.c0.uk:80/story_0"),
|
||||||
("http://mydomain.tld/2_%C3%A4", "decrement", "http://mydomain.tld/1_%C3%A4"),
|
("http://mydomain.tld/2_%C3%A4", "decrement", "http://mydomain.tld/1_%C3%A4"),
|
||||||
])
|
])
|
||||||
def test_url_incdec_number(url, incdec, output):
|
def test_incdec_number(url, incdec, output):
|
||||||
"""Test url_incdec_number with valid URLs."""
|
"""Test incdec_number with valid URLs."""
|
||||||
new_url = urlutils.url_incdec_number(QUrl(url), incdec)
|
new_url = urlutils.incdec_number(QUrl(url), incdec)
|
||||||
assert new_url == QUrl(output)
|
assert new_url == QUrl(output)
|
||||||
|
|
||||||
@pytest.mark.parametrize('url', [
|
@pytest.mark.parametrize('url', [
|
||||||
@ -549,14 +549,14 @@ def test_url_incdec_number(url, incdec, output):
|
|||||||
"http://example.com/%C3%B6/urlencoded/data",
|
"http://example.com/%C3%B6/urlencoded/data",
|
||||||
"http://www2.ex4mple.com:42/all/of/the/%C3%A4bove",
|
"http://www2.ex4mple.com:42/all/of/the/%C3%A4bove",
|
||||||
])
|
])
|
||||||
def test_url_incdec_number_invalid(url):
|
def test_incdec_number_invalid(url):
|
||||||
"""Test url_incdec_number with URLs that don't contain a number."""
|
"""Test incdec_number with URLs that don't contain a number."""
|
||||||
with pytest.raises(urlutils.IncDecError):
|
with pytest.raises(urlutils.IncDecError):
|
||||||
urlutils.url_incdec_number(QUrl(url), "increment")
|
urlutils.incdec_number(QUrl(url), "increment")
|
||||||
|
|
||||||
def test_url_incdec_number_below_0():
|
def test_incdec_number_below_0():
|
||||||
"""Test url_incdec_number with a number that would be below zero
|
"""Test incdec_number with a number that would be below zero
|
||||||
after decrementing."""
|
after decrementing."""
|
||||||
with pytest.raises(urlutils.IncDecError):
|
with pytest.raises(urlutils.IncDecError):
|
||||||
urlutils.url_incdec_number(QUrl('http://example.com/page_0.html'),
|
urlutils.incdec_number(QUrl('http://example.com/page_0.html'),
|
||||||
'decrement')
|
'decrement')
|
||||||
|
Loading…
Reference in New Issue
Block a user