From c4c3a83ac0c2af1a90a73281cbe123e473c337bf Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 8 Aug 2015 00:08:06 +0200 Subject: [PATCH] rename url_incdec_number to incdec_number --- qutebrowser/browser/commands.py | 2 +- qutebrowser/utils/urlutils.py | 4 ++-- tests/utils/test_urlutils.py | 18 +++++++++--------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 2c9404f93..ef7a16933 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -472,7 +472,7 @@ class CommandDispatcher: window: Open the link in a new window. """ try: - new_url = urlutils.url_incdec_number(url, incdec) + new_url = urlutils.incdec_number(url, incdec) except urlutils.IncDecError as error: raise cmdexc.CommandError(error.msg) self._open(new_url, tab, background, window) diff --git a/qutebrowser/utils/urlutils.py b/qutebrowser/utils/urlutils.py index f6bfe5701..a1348f41b 100644 --- a/qutebrowser/utils/urlutils.py +++ b/qutebrowser/utils/urlutils.py @@ -447,7 +447,7 @@ class FuzzyUrlError(Exception): class IncDecError(Exception): - """Exception raised by url_incdec_number on problems. + """Exception raised by incdec_number on problems. Attributes: msg: The error message. @@ -463,7 +463,7 @@ class IncDecError(Exception): 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. Args: diff --git a/tests/utils/test_urlutils.py b/tests/utils/test_urlutils.py index 520f3d891..b6b41eef5 100644 --- a/tests/utils/test_urlutils.py +++ b/tests/utils/test_urlutils.py @@ -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://mydomain.tld/2_%C3%A4", "decrement", "http://mydomain.tld/1_%C3%A4"), ]) -def test_url_incdec_number(url, incdec, output): - """Test url_incdec_number with valid URLs.""" - new_url = urlutils.url_incdec_number(QUrl(url), incdec) +def test_incdec_number(url, incdec, output): + """Test incdec_number with valid URLs.""" + new_url = urlutils.incdec_number(QUrl(url), incdec) assert new_url == QUrl(output) @pytest.mark.parametrize('url', [ @@ -549,14 +549,14 @@ def test_url_incdec_number(url, incdec, output): "http://example.com/%C3%B6/urlencoded/data", "http://www2.ex4mple.com:42/all/of/the/%C3%A4bove", ]) -def test_url_incdec_number_invalid(url): - """Test url_incdec_number with URLs that don't contain a number.""" +def test_incdec_number_invalid(url): + """Test incdec_number with URLs that don't contain a number.""" 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(): - """Test url_incdec_number with a number that would be below zero +def test_incdec_number_below_0(): + """Test incdec_number with a number that would be below zero after decrementing.""" 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')