jenkins-bot has submitted this change and it was merged.
Change subject: PEP257 on tests folder, Some minor manual changes in docstring
......................................................................
PEP257 on tests folder, Some minor manual changes in docstring
The fixations has been done by a self-written script, checked by hand
Change-Id: Id7e9ff5ab91806f2e3ab5fc4700a853386f5a8bd
---
M tests/api_tests.py
M tests/archivebot_tests.py
M tests/date_tests.py
M tests/dry_site_tests.py
M tests/http_tests.py
M tests/i18n_tests.py
M tests/ipregex_tests.py
M tests/namespace_tests.py
M tests/page_tests.py
M tests/pagegenerators_tests.py
M tests/pwb_tests.py
M tests/site_tests.py
M tests/timestripper_tests.py
M tests/ui_tests.py
M tests/utils.py
M tests/wikibase_tests.py
M tests/wikidataquery_tests.py
M tests/xmlreader_tests.py
18 files changed, 93 insertions(+), 143 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/api_tests.py b/tests/api_tests.py
index ef6fedf..f595a2b 100644
--- a/tests/api_tests.py
+++ b/tests/api_tests.py
@@ -94,7 +94,7 @@
self.gen.set_maximum_items('test')
def test_limits(self):
- """Test that PageGenerator yields the requested amount of
pages"""
+ """Test that PageGenerator yields the requested amount of
pages."""
for i in range(4, 0, -1):
self.gen.set_maximum_items(i) # set total amount of pages
results = [p for p in self.gen]
diff --git a/tests/archivebot_tests.py b/tests/archivebot_tests.py
index 8539ef3..e5672b5 100644
--- a/tests/archivebot_tests.py
+++ b/tests/archivebot_tests.py
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
-"""
-Tests for several scripts.
-"""
+"""Tests for archivebot scripts."""
#
# (C) Pywikibot team, 2014
#
@@ -33,7 +31,7 @@
def test_method(code):
def test_archivebot(self):
- """Test archivebot for one site"""
+ """Test archivebot for one site."""
site = pywikibot.Site(code, 'wikipedia')
page = pywikibot.Page(site, 'user talk:xqt')
talk = archivebot.DiscussionPage(page, None)
@@ -89,7 +87,7 @@
class TestArchiveBot(PywikibotTestCase):
- """Test archivebot script"""
+ """Test archivebot script."""
__metaclass__ = TestArchiveBotMeta
diff --git a/tests/date_tests.py b/tests/date_tests.py
index 7d9a81f..c03318d 100644
--- a/tests/date_tests.py
+++ b/tests/date_tests.py
@@ -14,12 +14,12 @@
"""Test meta class"""
def __new__(cls, name, bases, dct):
- """create the new class"""
+ """Create the new class"""
def test_method(formatname):
def testMapEntry(self):
- """The test ported from date.py"""
+ """The test ported from date.py."""
step = 1
if formatname in date.decadeFormats:
step = 10
@@ -50,7 +50,9 @@
class TestDate(NoSiteTestCase):
- """Test cases for date library processed by
unittest"""
+
+ """Test cases for date library processed by
unittest."""
+
__metaclass__ = TestDateMeta
diff --git a/tests/dry_site_tests.py b/tests/dry_site_tests.py
index 359f045..ff75020 100644
--- a/tests/dry_site_tests.py
+++ b/tests/dry_site_tests.py
@@ -46,6 +46,7 @@
class TestMustBe(NoSiteTestCase):
+
"""Test cases for the must_be decorator."""
# Implemented without setUpClass(cls) and global variables as objects
@@ -110,7 +111,8 @@
class TestNeedVersion(NoSiteTestCase):
- """Test cases for the must_be decorator."""
+
+ """Test cases for the need_version decorator."""
# Implemented without setUpClass(cls) and global variables as objects
# were not completely disposed and recreated but retained 'memory'
diff --git a/tests/http_tests.py b/tests/http_tests.py
index c00fc86..4a200e5 100644
--- a/tests/http_tests.py
+++ b/tests/http_tests.py
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
-"""
-Tests for http module.
-"""
+"""Tests for http module."""
#
# (C) Pywikibot team, 2014
#
diff --git a/tests/i18n_tests.py b/tests/i18n_tests.py
index 2d16042..8f969f8 100644
--- a/tests/i18n_tests.py
+++ b/tests/i18n_tests.py
@@ -114,10 +114,11 @@
class TestTWNTranslate(TestTWN):
- " Test {{PLURAL:}} support "
+
+ """Test {{PLURAL:}} support."""
def testNumber(self):
- """ use a number """
+ """Use a number..."""
self.assertEqual(
i18n.twntranslate('de', 'test-plural', 0) % {'num':
0},
u'Bot: Ändere 0 Seiten.')
@@ -144,25 +145,25 @@
u'Bot: Changing three pages.')
def testString(self):
- """ use a string """
+ """Use a string."""
self.assertEqual(
i18n.twntranslate('en', 'test-plural', '1') %
{'num': 'one'},
u'Bot: Changing one page.')
def testDict(self):
- """ use a dictionary """
+ """Use a dictionary."""
self.assertEqual(
i18n.twntranslate('en', 'test-plural', {'num': 2}),
u'Bot: Changing 2 pages.')
def testExtended(self):
- """ use additional format strings """
+ """Use additional format strings."""
self.assertEqual(
i18n.twntranslate('fr', 'test-plural', {'num': 1,
'descr': 'seulement'}),
u'Robot: Changer seulement une page.')
def testExtendedOutside(self):
- """ use additional format strings also outside """
+ """Use additional format strings also outside."""
self.assertEqual(
i18n.twntranslate('fr', 'test-plural', 1) % {'descr':
'seulement'},
u'Robot: Changer seulement une page.')
@@ -210,7 +211,7 @@
u'Bot: Ändere 11 Zeilen von mehreren Seiten.')
def testMultipleWrongParameterLength(self):
- """ Test wrong parameter lenght"""
+ """Test wrong parameter lenght."""
with self.assertRaisesRegexp(ValueError, "Length of parameter does not match
PLURAL occurences"):
self.assertEqual(
i18n.twntranslate('de', 'test-multiple-plurals', (1, 2))
@@ -224,7 +225,7 @@
u'Bot: Ändere dreihunderteinundzwanzig Zeilen von mehreren
Seiten.')
def testMultipleNonNumbers(self):
- """ Numbers or string numbers are required for tuple or list items
"""
+ """Numbers or string numbers are required for tuple or list
items."""
with self.assertRaisesRegexp(ValueError, "invalid literal for int\(\) with
base 10: 'drei'"):
self.assertEqual(
i18n.twntranslate('de', 'test-multiple-plurals',
["drei", "1", 1])
diff --git a/tests/ipregex_tests.py b/tests/ipregex_tests.py
index 01fa79b..b51fdf7 100644
--- a/tests/ipregex_tests.py
+++ b/tests/ipregex_tests.py
@@ -11,7 +11,7 @@
class PyWikiIpRegexCase(NoSiteTestCase):
- """Unit test class for ip_regexp"""
+ """Unit test class for ip_regexp."""
def setUp(self):
self.total = 0
diff --git a/tests/namespace_tests.py b/tests/namespace_tests.py
index feaa0ea..cbf177c 100644
--- a/tests/namespace_tests.py
+++ b/tests/namespace_tests.py
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
-"""
-Tests for the Namespace class.
-"""
+"""Tests for the Namespace class."""
#
# (C) Pywikibot team, 2014
#
@@ -19,6 +17,7 @@
class TestNamespaceObject(NoSiteTestCase):
+
"""Test cases for Namespace class."""
# These should work in any MW wiki
@@ -51,8 +50,7 @@
all_builtin_ids = dict(builtin_ids.items() + old_builtin_ids.items())
def testNamespaceTypes(self):
- """Test cases for methods manipulating namespace
names"""
-
+ """Test cases for methods manipulating namespace
names."""
ns = Namespace.builtin_namespaces(use_image_name=False)
self.assertType(ns, dict)
diff --git a/tests/page_tests.py b/tests/page_tests.py
index dca5d2f..7da9593 100644
--- a/tests/page_tests.py
+++ b/tests/page_tests.py
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
-"""
-Tests for the page module.
-"""
+"""Tests for the page module."""
#
# (C) Pywikibot team, 2008-2014
#
@@ -23,7 +21,8 @@
class TestLinkObject(PywikibotTestCase):
- """Test cases for Link objects"""
+
+ """Test cases for Link objects."""
enwiki = pywikibot.Site("en", "wikipedia")
frwiki = pywikibot.Site("fr", "wikipedia")
diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py
index f5183bb..c564e6a 100644
--- a/tests/pagegenerators_tests.py
+++ b/tests/pagegenerators_tests.py
@@ -14,7 +14,8 @@
class TestPageGenerators(PywikibotTestCase):
- """Test pagegenerators methods"""
+
+ """Test pagegenerators methods."""
titles = [
# just a bunch of randomly selected titles
diff --git a/tests/pwb_tests.py b/tests/pwb_tests.py
index c6aaf77..deffdae 100644
--- a/tests/pwb_tests.py
+++ b/tests/pwb_tests.py
@@ -25,7 +25,8 @@
class TestPwb(SiteTestCase):
- """Test pwb.py functionality.
+ """
+ Test pwb.py functionality.
This is registered as a Site test because it will not run
without a user-config.py
@@ -41,8 +42,12 @@
os.environ['PYWIKIBOT2_DIR'] =
self.oldenviron['PYWIKIBOT2_DIR']
def testScriptEnvironment(self):
- """Make sure the environment is not contaminated, and is the same
as
- the environment we get when directly running a script."""
+ """
+ Test environment of pywikibot.
+
+ Make sure the environment is not contaminated, and is the same as
+ the environment we get when directly running a script.
+ """
test = os.path.join(testbasepath, 'print_locals.py')
direct = check_output([pypath, test])
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 63b1f48..7f8518f 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
-"""
-Tests for the site module.
-"""
+"""Tests for the site module."""
#
# (C) Pywikibot team, 2008-2014
#
@@ -27,7 +25,9 @@
class TestSiteObject(PywikibotTestCase):
+
"""Test cases for Site methods."""
+
family = "wikipedia"
code = "en"
@@ -39,7 +39,7 @@
imagepage = next(iter(mainpage.imagelinks())) # 1st image on main page
def testBaseMethods(self):
- """Test cases for BaseSite methods"""
+ """Test cases for BaseSite methods."""
self.assertEqual(mysite.family.name, self.family)
self.assertEqual(mysite.code, self.code)
self.assertType(mysite.lang, basestring)
@@ -65,7 +65,7 @@
self.assertType(mysite.has_right(rgt), bool)
def testConstructors(self):
- """Test cases for site constructors"""
+ """Test cases for site constructors."""
self.assertEqual(pywikibot.site.APISite.fromDBName('enwiki'),
pywikibot.Site('en', 'wikipedia'))
self.assertEqual(pywikibot.site.APISite.fromDBName('eswikisource'),
pywikibot.Site('es', 'wikisource'))
self.assertEqual(pywikibot.site.APISite.fromDBName('dewikinews'),
pywikibot.Site('de', 'wikinews'))
@@ -76,7 +76,6 @@
def testLanguageMethods(self):
"""Test cases for languages() and related
methods"""
-
langs = mysite.languages()
self.assertType(langs, list)
self.assertTrue(mysite.code in langs)
@@ -89,8 +88,7 @@
self.assertTrue(item in langs, item)
def testNamespaceMethods(self):
- """Test cases for methods manipulating namespace
names"""
-
+ """Test cases for methods manipulating namespace
names."""
builtins = {
'': 0, # these should work in any MW wiki
'Talk': 1,
@@ -156,8 +154,7 @@
self.assertIn('WP', namespaces[4])
def testApiMethods(self):
- """Test generic ApiSite methods"""
-
+ """Test generic ApiSite methods."""
self.assertType(mysite.logged_in(), bool)
self.assertType(mysite.logged_in(True), bool)
self.assertType(mysite.userinfo, dict)
@@ -206,8 +203,7 @@
self.assertEqual(mysite.list_to_text(('This', 'that', 'the
other')), 'This, that and the other')
def testPageMethods(self):
- """Test ApiSite methods for getting page-specific
info"""
-
+ """Test ApiSite methods for getting page-specific
info."""
self.assertType(mysite.page_exists(mainpage), bool)
self.assertType(mysite.page_restrictions(mainpage), dict)
self.assertType(mysite.page_can_be_edited(mainpage), bool)
@@ -223,15 +219,13 @@
self.assertEqual(a[0], mainpage)
def testTokens(self):
- """Test ability to get page tokens"""
-
+ """Test ability to get page tokens."""
for ttype in ("edit", "move"): # token types for non-sysops
self.assertType(mysite.token(mainpage, ttype), basestring)
self.assertRaises(KeyError, mysite.token, mainpage, "invalidtype")
def testPreload(self):
- """Test that preloading works"""
-
+ """Test that preloading works."""
count = 0
for page in mysite.preloadpages(mysite.pagelinks(mainpage, total=10)):
self.assertType(page, pywikibot.Page)
@@ -243,8 +237,7 @@
break
def testItemPreload(self):
- """Test that ItemPage preloading works"""
-
+ """Test that ItemPage preloading works."""
datasite = mysite.data_repository()
items = [pywikibot.ItemPage(datasite, 'q' + str(num)) for num in range(1,
6)]
@@ -252,8 +245,7 @@
self.assertTrue(hasattr(page, '_content'))
def testLinkMethods(self):
- """Test site methods for getting links to and from a
page"""
-
+ """Test site methods for getting links to and from a
page."""
backlinks = set(mysite.pagebacklinks(mainpage, namespaces=[0]))
# only non-redirects:
filtered = set(mysite.pagebacklinks(mainpage, namespaces=0,
@@ -328,7 +320,6 @@
def testAllPages(self):
"""Test the site.allpages() method"""
-
fwd = list(mysite.allpages(total=10))
self.assertTrue(len(fwd) <= 10)
for page in fwd:
@@ -395,7 +386,6 @@
def testAllLinks(self):
"""Test the site.alllinks() method"""
-
fwd = list(mysite.alllinks(total=10))
self.assertTrue(len(fwd) <= 10)
self.assertTrue(all(isinstance(link, pywikibot.Page) for link in fwd))
@@ -422,7 +412,6 @@
def testAllCategories(self):
"""Test the site.allcategories() method"""
-
ac = list(mysite.allcategories(total=10))
self.assertTrue(len(ac) <= 10)
self.assertTrue(all(isinstance(cat, pywikibot.Category)
@@ -440,7 +429,6 @@
def testAllUsers(self):
"""Test the site.allusers() method"""
-
au = list(mysite.allusers(total=10))
self.assertTrue(len(au) <= 10)
for user in au:
@@ -470,7 +458,6 @@
def testAllImages(self):
"""Test the site.allimages() method"""
-
ai = list(mysite.allimages(total=10))
self.assertTrue(len(ai) <= 10)
self.assertTrue(all(isinstance(image, pywikibot.FilePage)
@@ -499,7 +486,6 @@
def testBlocks(self):
"""Test the site.blocks() method"""
-
props = ("id", "by", "timestamp",
"expiry", "reason")
bl = list(mysite.blocks(total=10))
self.assertTrue(len(bl) <= 10)
@@ -557,7 +543,6 @@
def testExturlusage(self):
"""Test the site.exturlusage() method"""
-
url = "www.google.com"
eu = list(mysite.exturlusage(url, total=10))
self.assertTrue(len(eu) <= 10)
@@ -569,7 +554,6 @@
def testImageusage(self):
"""Test the site.imageusage() method"""
-
iu = list(mysite.imageusage(imagepage, total=10))
self.assertTrue(len(iu) <= 10)
self.assertTrue(all(isinstance(link, pywikibot.Page)
@@ -586,7 +570,6 @@
def testLogEvents(self):
"""Test the site.logevents() method"""
-
le = list(mysite.logevents(total=10))
self.assertTrue(len(le) <= 10)
self.assertTrue(all(isinstance(entry, pywikibot.logentries.LogEntry)
@@ -628,7 +611,6 @@
def testRecentchanges(self):
"""Test the site.recentchanges() method"""
-
rc = list(mysite.recentchanges(total=10))
self.assertTrue(len(rc) <= 10)
self.assertTrue(all(isinstance(change, dict)
@@ -748,7 +730,6 @@
def testUsercontribs(self):
"""Test the site.usercontribs() method"""
-
uc = list(mysite.usercontribs(user=mysite.user(), total=10))
self.assertTrue(len(uc) <= 10)
self.assertTrue(all(isinstance(contrib, dict)
@@ -821,7 +802,6 @@
def testWatchlistrevs(self):
"""Test the site.watchlist_revs() method"""
-
wl = list(mysite.watchlist_revs(total=10))
self.assertTrue(len(wl) <= 10)
self.assertTrue(all(isinstance(rev, dict)
@@ -889,7 +869,6 @@
def testDeletedrevs(self):
"""Test the site.deletedrevs() method"""
-
if not mysite.logged_in(True):
try:
mysite.login(True)
@@ -948,7 +927,6 @@
def testUsers(self):
"""Test the site.users() method"""
-
us = list(mysite.users(mysite.user()))
self.assertEqual(len(us), 1)
self.assertType(us[0], dict)
@@ -960,7 +938,6 @@
def testRandompages(self):
"""Test the site.randompages() method"""
-
rn = list(mysite.randompages(total=10))
self.assertTrue(len(rn) <= 10)
self.assertTrue(all(isinstance(a_page, pywikibot.Page)
@@ -1056,6 +1033,7 @@
class TestSiteLoadRevisions(PywikibotTestCase):
+
"""Test cases for Site.loadrevision() method."""
# Implemented without setUpClass(cls) and global variables as objects
@@ -1068,7 +1046,6 @@
def testLoadRevisions_basic(self):
"""Test the site.loadrevisions() method"""
-
self.mysite.loadrevisions(self.mainpage, total=15)
self.assertTrue(hasattr(self.mainpage, "_revid"))
self.assertTrue(hasattr(self.mainpage, "_revisions"))
@@ -1078,13 +1055,11 @@
def testLoadRevisions_getText(self):
"""Test the site.loadrevisions() method with
getText=True"""
-
self.mysite.loadrevisions(self.mainpage, getText=True, total=5)
self.assertTrue(len(self.mainpage._text) > 0)
def testLoadRevisions_revids(self):
"""Test the site.loadrevisions() method, listing based on
revid."""
-
# revids as list of int
self.mysite.loadrevisions(self.mainpage, revids=[139992, 139993])
self.assertTrue(all(rev in self.mainpage._revisions for rev in [139992,
139993]))
@@ -1103,19 +1078,16 @@
def testLoadRevisions_querycontinue(self):
"""Test the site.loadrevisions() method with
query-continue"""
-
self.mysite.loadrevisions(self.mainpage, step=5, total=12)
self.assertEqual(len(self.mainpage._revisions), 12)
def testLoadRevisions_revdir(self):
"""Test the site.loadrevisions() method with
rvdir=True"""
-
self.mysite.loadrevisions(self.mainpage, rvdir=True, total=15)
self.assertEqual(len(self.mainpage._revisions), 15)
def testLoadRevisions_timestamp(self):
"""Test the site.loadrevisions() method, listing based on
timestamp."""
-
self.mysite.loadrevisions(self.mainpage, rvdir=True, total=15)
self.assertEqual(len(self.mainpage._revisions), 15)
revs = self.mainpage._revisions
@@ -1136,7 +1108,6 @@
def testLoadRevisions_rev_id(self):
"""Test the site.loadrevisions() method, listing based on
rev_id."""
-
self.mysite.loadrevisions(self.mainpage, rvdir=True, total=15)
self.assertEqual(len(self.mainpage._revisions), 15)
revs = self.mainpage._revisions
@@ -1156,7 +1127,6 @@
def testLoadRevisions_user(self):
"""Test the site.loadrevisions() method, filtering by
user."""
-
# Only list revisions made by this user.
self.mainpage._revisions = {}
self.mysite.loadrevisions(self.mainpage, rvdir=True,
@@ -1166,7 +1136,6 @@
def testLoadRevisions_excludeuser(self):
"""Test the site.loadrevisions() method, excluding
user."""
-
# Do not list revisions made by this user.
self.mainpage._revisions = {}
self.mysite.loadrevisions(self.mainpage, rvdir=True,
@@ -1178,7 +1147,9 @@
class TestCommonsSite(PywikibotTestCase):
+
"""Test cases for Site methods on Commons."""
+
family = "commons"
code = "commons"
diff --git a/tests/timestripper_tests.py b/tests/timestripper_tests.py
index c66e69f..07ae408 100644
--- a/tests/timestripper_tests.py
+++ b/tests/timestripper_tests.py
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
-"""
-Tests for archivebot.py/Timestripper.
-"""
+"""Tests for archivebot.py/Timestripper."""
#
# (C) Pywikibot team, 2014
#
@@ -17,7 +15,8 @@
class TestTimeStripperWithNoDigitsAsMonths(PywikibotTestCase):
- """Test cases for TimeStripper methods"""
+
+ """Test cases for TimeStripper methods."""
def setUp(self):
site = pywikibot.Site('fr', 'wikipedia')
@@ -25,15 +24,13 @@
super(TestTimeStripperWithNoDigitsAsMonths, self).setUp()
def test_findmarker(self):
- """Test that string which is not part of text is
found"""
-
+ """Test that string which is not part of text is
found."""
txt = u'this is a string with a maker is @@@@already present'
self.assertEqual(self.ts.findmarker(txt, base=u'@@',
delta='@@'),
'@@@@@@')
def test_last_match_and_replace(self):
"""Test that pattern matches and removes items
correctly."""
-
txtWithOneMatch = u'this string has 3000, 1999 and 3000 in it'
txtWithTwoMatch = u'this string has 1998, 1999 and 3000 in it'
txtWithNoMatch = u'this string has no match'
@@ -76,8 +73,7 @@
)
def test_timestripper(self):
- """Test that correct date is matched"""
-
+ """Test that correct date is matched."""
txtMatch = u'3 février 2010 à 19:48 (CET) 7 février 2010 à 19:48 (CET)'
txtNoMatch = u'3 March 2010 19:48 (CET) 7 March 2010 19:48 (CET)'
@@ -91,7 +87,8 @@
class TestTimeStripperWithDigitsAsMonths(PywikibotTestCase):
- """Test cases for TimeStripper methods"""
+
+ """Test cases for TimeStripper methods."""
def setUp(self):
site = pywikibot.Site('cs', 'wikipedia')
@@ -100,7 +97,6 @@
def test_last_match_and_replace(self):
"""Test that pattern matches and removes items
correctly."""
-
txtWithOneMatch = u'this string has XX. YY. 12. in it'
txtWithTwoMatch = u'this string has XX. 1. 12. in it'
txtWithThreeMatch = u'this string has 1. 1. 12. in it'
@@ -138,7 +134,8 @@
class TestEnglishTimeStripper(PywikibotTestCase):
- """Test cases for English language"""
+
+ """Test cases for English language."""
def setUp(self):
site = pywikibot.Site('en', 'wikipedia')
@@ -146,8 +143,7 @@
super(TestEnglishTimeStripper, self).setUp()
def test_timestripper(self):
- """Test that correct date is matched"""
-
+ """Test that correct date is matched."""
txtMatch = u'3 February 2010 19:48 (UTC) 7 February 2010 19:48 (UTC)'
txtNoMatch = u'3. 2. 2010, 19:48 (UTC) 7. 2. 2010 19:48 (UTC)'
@@ -161,7 +157,8 @@
class TestCzechTimeStripper(PywikibotTestCase):
- """Test cases for Czech language"""
+
+ """Test cases for Czech language."""
def setUp(self):
site = pywikibot.Site('cs', 'wikipedia')
@@ -169,8 +166,7 @@
super(TestCzechTimeStripper, self).setUp()
def test_timestripper(self):
- """Test that correct date is matched"""
-
+ """Test that correct date is matched."""
txtMatch = u'3. 2. 2010, 19:48 (UTC) 7. 2. 2010 19:48 (UTC)'
txtNoMatch = u'3 March 2010 19:48 (UTC) 7 March 2010 19:48 (UTC)'
@@ -184,7 +180,8 @@
class TestPortugueseTimeStripper(PywikibotTestCase):
- """Test cases for Portuguese language"""
+
+ """Test cases for Portuguese language."""
def setUp(self):
site = pywikibot.Site('pt', 'wikipedia')
@@ -192,8 +189,7 @@
super(TestPortugueseTimeStripper, self).setUp()
def test_timestripper(self):
- """Test that correct date is matched"""
-
+ """Test that correct date is matched."""
txtMatch = u'19h48min de 3 de fevereiro de 2010 (UTC) 19h48min de 7 de
fevereiro de 2010 (UTC)'
txtNoMatch = u'3 March 2010 19:48 (UTC) 7 March 2010 19:48 (UTC)'
@@ -207,7 +203,8 @@
class TestNorwegianTimeStripper(PywikibotTestCase):
- """Test cases for Norwegian language"""
+
+ """Test cases for Norwegian language."""
def setUp(self):
site = pywikibot.Site('no', 'wikipedia')
@@ -215,8 +212,7 @@
super(TestNorwegianTimeStripper, self).setUp()
def test_timestripper(self):
- """Test that correct date is matched"""
-
+ """Test that correct date is matched."""
txtMatch = u'3. feb 2010 kl. 19:48 (CET) 7. feb 2010 kl. 19:48 (UTC)'
txtNoMatch = u'3 March 2010 19:48 (UTC) 7 March 2010 19:48 (UTC)'
@@ -230,7 +226,8 @@
class TestVietnameseTimeStripper(PywikibotTestCase):
- """Test cases for Vietnamese language"""
+
+ """Test cases for Vietnamese language."""
def setUp(self):
site = pywikibot.Site('vi', 'wikipedia')
@@ -238,8 +235,7 @@
super(TestVietnameseTimeStripper, self).setUp()
def test_timestripper_01(self):
- """Test that correct date is matched"""
-
+ """Test that correct date is matched."""
txtMatch = u'16:41, ngày 15 tháng 9 năm 2008 (UTC) 16:41, ngày 12 tháng 9 năm
2008 (UTC)'
txtNoMatch = u'16:41, ngày 15 March 9 năm 2008 (UTC) 16:41, ngày 12 March 9
năm 2008 (UTC)'
@@ -252,8 +248,7 @@
self.assertEqual(self.ts.timestripper(txtNoMatch), None)
def test_timestripper_02(self):
- """Test that correct date is matched"""
-
+ """Test that correct date is matched."""
txtMatch = u'21:18, ngày 13 tháng 8 năm 2014 (UTC) 21:18, ngày 14 tháng 8 năm
2014 (UTC)'
txtNoMatch = u'21:18, ngày 13 March 8 năm 2014 (UTC) 21:18, ngày 14 March 8
năm 2014 (UTC)'
diff --git a/tests/ui_tests.py b/tests/ui_tests.py
index 130bbd4..87e1950 100644
--- a/tests/ui_tests.py
+++ b/tests/ui_tests.py
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
-"""
-Tests for the page module.
-"""
+"""Tests for the user interface."""
#
# (C) Pywikibot team, 2008-2014
#
diff --git a/tests/utils.py b/tests/utils.py
index 1c1bf2f..ef1a15f 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -40,7 +40,7 @@
"""
def assertType(self, obj, cls):
- """Assert that obj is an instance of type cls"""
+ """Assert that obj is an instance of type cls."""
return self.assertTrue(isinstance(obj, cls))
def setUp(self):
diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py
index 0f1cba9..961134c 100644
--- a/tests/wikibase_tests.py
+++ b/tests/wikibase_tests.py
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
-"""
-Tests for the Wikidata parts of the page module.
-"""
+"""Tests for the Wikidata parts of the page module."""
#
# (C) Pywikibot team, 2008-2014
#
@@ -423,7 +421,9 @@
class TestLinks(PywikibotTestCase):
- """Test cases to test links stored in Wikidata"""
+
+ """Test cases to test links stored in Wikidata."""
+
def setUp(self):
super(TestLinks, self).setUp()
self.wdp = pywikibot.ItemPage(wikidata, 'Q60')
diff --git a/tests/wikidataquery_tests.py b/tests/wikidataquery_tests.py
index ae6a08f..52c8416 100644
--- a/tests/wikidataquery_tests.py
+++ b/tests/wikidataquery_tests.py
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
-"""
-Test cases for the WikidataQuery query syntax and API
-"""
+"""Test cases for the WikidataQuery query syntax and
API."""
#
# (C) Pywikibot team, 2014
#
@@ -29,10 +27,11 @@
def testQueries(self):
"""
- Test that we produce the expected query strings and that
+ Test Queries and check whether they're behaving correctly.
+
+ Check that we produce the expected query strings and that
invalid inputs are rejected correctly
"""
-
q = query.HasClaim(99)
self.assertEqual(str(q), "claim[99]")
@@ -94,10 +93,7 @@
self.assertEqual(str(q), "claim[99:(tree[1][2,5][3,90])]")
def testQueriesWDStructures(self):
- """
- Queries using Wikibase page structures like ItemPage
- """
-
+ """Queries using Wikibase page structures like
ItemPage."""
q = query.HasClaim(PropertyPage(self.repo, "P99"))
self.assertEqual(str(q), "claim[99]")
@@ -145,10 +141,7 @@
self.assertEqual(str(q),
'between[569,-00000000044-01-01T00:00:00Z,+00000002010-01-01T01:00:00Z]')
def testQueriesDirectFromClaim(self):
- """
- Test construction of the right Query from a page.Claim
- """
-
+ """Test construction of the right Query from a
page.Claim."""
claim = Claim(self.repo, 'P17')
claim.setTarget(pywikibot.ItemPage(self.repo, 'Q35'))
@@ -162,10 +155,7 @@
self.assertEqual(str(q), 'string[268:"somestring"]')
def testQuerySets(self):
- """
- Test that we can join queries together correctly
- """
-
+ """Test that we can join queries together
correctly."""
# construct via queries
qs = query.HasClaim(99, 100).AND(query.HasClaim(99, 101))
@@ -212,10 +202,7 @@
self.assertEqual(str(qs), 'link[enwiki] AND nolink[dewiki]')
def testQueryApiSyntax(self):
- """
- Test that we can generate the API query correctly
- """
-
+ """Test that we can generate the API query
correctly."""
w = query.WikidataQuery("http://example.com")
qs = w.getQueryString(query.Link("enwiki"))
@@ -233,10 +220,7 @@
net = True
def testQueryApiGetter(self):
- """
- Test that we can actually retreive data and that caching works
- """
-
+ """Test that we can actually retreive data and that caching
works."""
w = query.WikidataQuery(cacheMaxAge=0)
# this query doesn't return any items, save a bit of bandwidth!
diff --git a/tests/xmlreader_tests.py b/tests/xmlreader_tests.py
index a353fad..955261c 100644
--- a/tests/xmlreader_tests.py
+++ b/tests/xmlreader_tests.py
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
-"""
-Tests for xmlreader module.
-"""
+"""Tests for xmlreader module."""
#
# (C) Pywikibot team, 2014
#
--
To view, visit
https://gerrit.wikimedia.org/r/155172
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id7e9ff5ab91806f2e3ab5fc4700a853386f5a8bd
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>