From 0a3300c89168c8046e8ff86d235bc8d2a8b6f513 Mon Sep 17 00:00:00 2001 From: Laurent Bachelier Date: Sun, 19 Oct 2014 00:15:38 +0200 Subject: [PATCH] browser tests: Fixes pyflakes/pep8, test name in setup.cfg, remove useless comments --- setup.cfg | 2 +- weboob/browser/tests_class_Form.py | 13 +++++++------ weboob/browser/tests_class_URL.py | 26 ++++++-------------------- 3 files changed, 14 insertions(+), 27 deletions(-) diff --git a/setup.cfg b/setup.cfg index 7fb18a7966..44866f0b98 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,7 +15,7 @@ tests = weboob.tools.capabilities.bank.transactions, weboob.browser.pages, weboob.browser.filters.standard, weboob.browser.tests_class_URL, - weboob.browser_tests_class_Form + weboob.browser.tests_class_Form [isort] known_first_party=weboob diff --git a/weboob/browser/tests_class_Form.py b/weboob/browser/tests_class_Form.py index abdcbe6b11..69469d69b0 100644 --- a/weboob/browser/tests_class_Form.py +++ b/weboob/browser/tests_class_Form.py @@ -15,12 +15,14 @@ # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . -from unittest import TestCase -from weboob.browser import URL -from weboob.browser.pages import Form, FormSubmitWarning, HTMLPage import collections -import lxml.html import warnings +from unittest import TestCase + +import lxml.html + +from weboob.browser import URL +from weboob.browser.pages import Form, FormSubmitWarning # Mock that allows to represent a Page @@ -48,7 +50,7 @@ def setUp(self): """) - self.elMoreSubmit = lxml.html.fromstring( + self.elMoreSubmit = lxml.html.fromstring( """
@@ -103,4 +105,3 @@ def test_warning_submit_not_find(self): assert len(w) == 1 assert issubclass(w[-1].category, FormSubmitWarning) assert warningMsg in str(w[-1].message) - diff --git a/weboob/browser/tests_class_URL.py b/weboob/browser/tests_class_URL.py index bde40bdcd3..742d428f6f 100644 --- a/weboob/browser/tests_class_URL.py +++ b/weboob/browser/tests_class_URL.py @@ -16,7 +16,8 @@ # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from unittest import TestCase -from weboob.browser import URL, PagesBrowser + +from weboob.browser import PagesBrowser, URL from weboob.browser.pages import Page from weboob.browser.url import UrlNotResolvable @@ -27,7 +28,7 @@ class MyMockBrowserWithoutBrowser(): # Mock that allows to represent a Page -class myMockPage(Page): +class MyMockPage(Page): pass @@ -46,8 +47,8 @@ class MyMockBrowser(PagesBrowser): urlParams = URL("http://test.com\?id=(?P\d+)&name=(?P.+)") # URL used by method is_here - urlIsHere = URL('http://weboob.org/(?P)', myMockPage) - urlIsHereDifKlass = URL('http://free.fr', myMockPage) + urlIsHere = URL('http://weboob.org/(?P)', MyMockPage) + urlIsHereDifKlass = URL('http://free.fr', MyMockPage) # Class that tests different methods from the class URL @@ -58,8 +59,6 @@ def setUp(self): self.myBrowser = MyMockBrowser() self.myBrowserWithoutBrowser = MyMockBrowserWithoutBrowser() -# TESTS FOR MATCH METHOD - # Check that an assert is sent if both base and browser are none def test_match_base_none_browser_none(self): self.assertRaises(AssertionError, @@ -79,41 +78,31 @@ def test_match_base_not_none_browser_none(self): # Check that none is returned when none of the defined urls is a regex for # the given url def test_match_url_pasregex_baseurl(self): - # Test res = self.myBrowser.urlNotRegex.match("http://weboob.org/news") - # Assertions self.assertIsNone(res) # Check that true is returned when one of the defined urls is a regex # for the given url def test_match_url_regex_baseurl(self): - # Test res = self.myBrowser.urlRegex.match("http://weboob2.org/news") - # Assertions self.assertTrue(res) # Successful test with relatives url def test_match_url_without_http(self): - # Test res = self.myBrowser.urlRegWithoutHttp.match("http://weboob.org/news") - # Assertions self.assertTrue(res) # Unsuccessful test with relatives url def test_match_url_without_http_fail(self): - # Test browser = self.myBrowser res = browser.urlNotRegWithoutHttp.match("http://weboob.org/news") - # Assertions self.assertIsNone(res) -# TESTS FOR BUILD METHOD - # Checks that build returns the right url when it needs to add # the value of a parameter def test_build_nominal_case(self): res = self.myBrowser.urlValue.build(id=2) - self.assertEquals(res, "http://test.com/2") + self.assertEquals(res, "http://test.com/2") # Checks that build returns the right url when it needs to add # identifiers and values of some parameters @@ -133,11 +122,8 @@ def test_build_urlParams_KO_moreparams(self): self.assertRaises(UrlNotResolvable, self.myBrowser.urlParams.build, id=2, name="weboob", title="test") -# TESTS FOR IS_HERE METHOD - # Check that an assert is sent if both klass is none def test_ishere_klass_none(self): self.assertRaisesRegexp(AssertionError, "You can use this method" + " only if there is a Page class handler.", self.myBrowser.urlRegex.is_here, id=2) - -- GitLab