jenkins-bot has submitted this change and it was merged.

Change subject: [FIX] pagegen tests: normalize page titles
......................................................................


[FIX] pagegen tests: normalize page titles

On the wiktionary the main namespace is case sensitive but the test
didn't account for this.

Change-Id: I1e6f64eee2fe81754011c7fa13db8405de14626e
---
M tests/aspects.py
M tests/pagegenerators_tests.py
2 files changed, 13 insertions(+), 6 deletions(-)

Approvals:
  John Vandenberg: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/aspects.py b/tests/aspects.py
index d0cfe31..f134dcc 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -134,7 +134,7 @@
         else:
             self.assertEqual(set(page_namespaces), namespaces)
 
-    def assertPagelistTitles(self, gen, titles):
+    def assertPagelistTitles(self, gen, titles, site=None):
         """
         Test that pages in gen match expected titles.
 
@@ -146,18 +146,25 @@
         @param titles: Expected titles
         @type titles: tuple or list
         """
-        if isinstance(titles, tuple):
+        is_tuple = isinstance(titles, tuple)
+        if site:
+            titles = [pywikibot.Link(title, site).canonical_title()
+                      for title in titles]
+            if is_tuple:
+                titles = tuple(titles)
+
+        if is_tuple:
             working_set = collections.deque(titles)
 
         for page in gen:
             title = page.title()
             self.assertIn(title, titles)
-            if isinstance(titles, tuple):
+            if is_tuple:
                 self.assertIn(title, working_set)
                 self.assertEqual(title, working_set[0])
                 working_set.popleft()
 
-        if isinstance(titles, tuple):
+        if is_tuple:
             self.assertEqual(working_set, collections.deque([]))
 
 
diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py
index 64c30d1..9492579 100755
--- a/tests/pagegenerators_tests.py
+++ b/tests/pagegenerators_tests.py
@@ -194,13 +194,13 @@
         filename = os.path.join(_data_dir, 'pagelist-brackets.txt')
         site = self.get_site()
         titles = list(pagegenerators.TextfilePageGenerator(filename, site))
-        self.assertPagelistTitles(titles, self.expected_titles)
+        self.assertPagelistTitles(titles, self.expected_titles, site)
 
     def test_lines(self):
         filename = os.path.join(_data_dir, 'pagelist-lines.txt')
         site = self.get_site()
         titles = list(pagegenerators.TextfilePageGenerator(filename, site))
-        self.assertPagelistTitles(titles, self.expected_titles)
+        self.assertPagelistTitles(titles, self.expected_titles, site)
 
 
 class TestDequePreloadingGenerator(DefaultSiteTestCase):

-- 
To view, visit https://gerrit.wikimedia.org/r/172184
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1e6f64eee2fe81754011c7fa13db8405de14626e
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: XZise <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to