jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/463609 )
Change subject: [cleanup] cleanup tests/[cache_tests.py-cosmetic_changes_tests.py] ......................................................................
[cleanup] cleanup tests/[cache_tests.py-cosmetic_changes_tests.py]
- use single quotes for string literals - remove preleading "u" fron strings - indentation to make sure code lines are less than 79 characters
Change-Id: I7a192498e484521f2f7b721e71ab571b6068b14d --- M tests/category_bot_tests.py M tests/category_tests.py M tests/conftest.py M tests/cosmetic_changes_tests.py 4 files changed, 39 insertions(+), 26 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/category_bot_tests.py b/tests/category_bot_tests.py index 84e67b5..da3d34b 100644 --- a/tests/category_bot_tests.py +++ b/tests/category_bot_tests.py @@ -26,25 +26,25 @@ """Test CFD (Categories for deletion) actions."""
def test_strip_cfd_templates_does_nothing_when_no_templates(self): - """Test that when there are no CFD templates, the page text is not changed.""" + """Test when the're no CFD templates, the page text is not changed.""" bot = CategoryMoveRobot(oldcat='Old', newcat='New') - bot.newcat.text = "Nothing should change.\n\nAnother line." + bot.newcat.text = 'Nothing should change.\n\nAnother line.' bot._strip_cfd_templates(commit=False) self.assertEqual(bot.newcat.text, - "Nothing should change.\n\nAnother line.") + 'Nothing should change.\n\nAnother line.')
def test_strip_cfd_templates_with_spaces_in_comments(self): - """Test that CFD templates with spaces in the syntax are removed properly.""" + """Test CFD templates with spaces in the syntax are removed.""" self._runtest_strip_cfd_templates('<!-- BEGIN CFD TEMPLATE -->', '<!-- END CFD TEMPLATE -->')
def test_strip_cfd_templates_without_spaces_in_comments(self): - """Test that CFD templates without spaces in the syntax are removed properly.""" + """Test CFD templates without spaces in the syntax are removed.""" self._runtest_strip_cfd_templates('<!--BEGIN CFD TEMPLATE-->', '<!--END CFD TEMPLATE-->')
def _runtest_strip_cfd_templates(self, template_start, template_end): - """Run a CFD template stripping test with the given CFD start/end templates.""" + """Run a CFD template stripping test, given CFD start/end templates.""" bot = CategoryMoveRobot(oldcat='Old', newcat='New') bot.newcat.text = '\n'.join(( 'Preamble', diff --git a/tests/category_tests.py b/tests/category_tests.py index 222fe13..0d6bc5c 100644 --- a/tests/category_tests.py +++ b/tests/category_tests.py @@ -36,7 +36,8 @@ """Test if category is empty or not.""" site = self.get_site() cat_empty = pywikibot.Category(site, 'Category:foooooo') - cat_not_empty = pywikibot.Category(site, 'Category:Wikipedia categories') + cat_not_empty = pywikibot.Category(site, + 'Category:Wikipedia categories') self.assertTrue(cat_empty.isEmptyCategory()) self.assertFalse(cat_not_empty.isEmptyCategory())
@@ -57,10 +58,12 @@ self.assertTrue(categoryinfo['pages'] >= 0) self.assertTrue(categoryinfo['size'] > 0) self.assertTrue(categoryinfo['subcats'] > 0) - members_sum = categoryinfo['files'] + categoryinfo['pages'] + categoryinfo['subcats'] + members_sum = (categoryinfo['files'] + categoryinfo['pages'] + + categoryinfo['subcats']) self.assertEqual(members_sum, categoryinfo['size'])
- cat_files = pywikibot.Category(site, 'Category:Files lacking an author') + cat_files = pywikibot.Category(site, + 'Category:Files lacking an author') categoryinfo2 = cat_files.categoryinfo self.assertTrue(categoryinfo2['files'] > 0)
@@ -152,7 +155,8 @@
# Raise exception if target is fetched for non Category redirects. self.assertRaisesRegex(pywikibot.IsNotRedirectPage, - self.NOREDIRECTPAGE_RE, cat2.getCategoryRedirectTarget) + self.NOREDIRECTPAGE_RE, + cat2.getCategoryRedirectTarget)
class TestCategoryDryObject(TestCase): @@ -222,20 +226,23 @@ site = self.get_site() cat = pywikibot.Category(site, 'Category:Wikipedia Categories') self.assertEqual(cat.title(as_link=True, insite=cat.site), - u'[[Category:Wikipedia Categories]]') - cat_section = pywikibot.Category(site, 'Category:Wikipedia Categories#Foo') + '[[Category:Wikipedia Categories]]') + cat_section = pywikibot.Category(site, + 'Category:Wikipedia Categories#Foo') self.assertEqual( cat_section.title(as_link=True, insite=cat_section.site), '[[Category:Wikipedia Categories#Foo]]') cat_dup = pywikibot.Category(site, 'Category:Wikipedia:Test') self.assertEqual(cat_dup.title(as_link=True, insite=cat_dup.site), - u'[[Category:Wikipedia:Test]]') + '[[Category:Wikipedia:Test]]')
def test_sortkey(self): """Test the sortKey attribute.""" site = self.get_site() - cat = pywikibot.Category(site, 'Category:Wikipedia categories', 'Example') - self.assertEqual(cat.aslink(), '[[Category:Wikipedia categories|Example]]') + cat = pywikibot.Category(site, 'Category:Wikipedia categories', + 'Example') + self.assertEqual(cat.aslink(), + '[[Category:Wikipedia categories|Example]]') self.assertEqual(cat.aslink(sort_key='Foo'), '[[Category:Wikipedia categories|Foo]]')
@@ -251,7 +258,7 @@
def test_newest_pages(self): """Test that the pages are getting older.""" - cat = pywikibot.Category(self.get_site(), u'Catégorie:Yukon Quest 2015') + cat = pywikibot.Category(self.get_site(), 'Catégorie:Yukon Quest 2015') last = pywikibot.Timestamp.max count = 0 for page in cat.newest_pages(): diff --git a/tests/conftest.py b/tests/conftest.py index 0af46cf..cbaa39a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -11,5 +11,5 @@
def pytest_configure(config): - """Set the sys._test_runner_pytest flag to True, if pytest is used to run tests.""" + """Set the sys._test_runner_pytest flag to True, if pytest is used.""" sys._test_runner_pytest = True diff --git a/tests/cosmetic_changes_tests.py b/tests/cosmetic_changes_tests.py index f038733..bf56944 100644 --- a/tests/cosmetic_changes_tests.py +++ b/tests/cosmetic_changes_tests.py @@ -60,7 +60,8 @@ """Test resolveHtmlEntities method.""" self.assertEqual( '&# # #0#>#x', - self.cct.resolveHtmlEntities('&# # #0#>#x')) + self.cct.resolveHtmlEntities( + '&# # #0#>#x')) self.assertEqual( '<code> </code>', self.cct.resolveHtmlEntities('<code> </code>')) @@ -213,13 +214,17 @@ '[[:Datei:Example.svg|Description]]\n', self.cct.fixSyntaxSave( '[https://de.wikipedia.org/wiki/Kategorie:Example%5D%5Cn' - '[https://de.wikipedia.org/wiki/Category:Example Description]\n' + '[https://de.wikipedia.org/wiki/Category:Example ' + 'Description]\n' '[https://de.wikipedia.org/wiki/Datei:Example.svg%5D%5Cn' - '[https://de.wikipedia.org/wiki/File:Example.svg Description]\n' + '[https://de.wikipedia.org/wiki/File:Example.svg ' + 'Description]\n' '[[https://de.wikipedia.org/wiki/Category:Example%5D%5D%5Cn' - '[[https://de.wikipedia.org/wiki/Kategorie:Example Description]]\n' + '[[https://de.wikipedia.org/wiki/Kategorie:Example ' + 'Description]]\n' '[[https://de.wikipedia.org/wiki/File:Example.svg%5D%5D%5Cn' - '[[https://de.wikipedia.org/wiki/Datei:Example.svg Description]]\n' + '[[https://de.wikipedia.org/wiki/Datei:Example.svg ' + 'Description]]\n' )) del self.cct.site._namespaces
@@ -438,8 +443,8 @@ """ Test cleanUpLinks method.
- This method fails for the given samples from library. Either the method - has to be changed or the examples must be fixed. + This method fails for the given samples from library. Either + the method has to be changed or the examples must be fixed. """ self.assertEqual('text [[title]] text', self.cct.cleanUpLinks('text[[ title ]]text')) @@ -454,8 +459,9 @@ """Test replaceDeprecatedTemplates method.""" self.assertEqual('{{Belege fehlen}}', self.cct.replaceDeprecatedTemplates('{{Belege}}')) - self.assertEqual('{{Belege fehlen|Test}}', - self.cct.replaceDeprecatedTemplates('{{Quelle|Test}}')) + self.assertEqual( + '{{Belege fehlen|Test}}', + self.cct.replaceDeprecatedTemplates('{{Quelle|Test}}'))
class TestCosmeticChangesPersian(TestCosmeticChanges):
pywikibot-commits@lists.wikimedia.org