Page MenuHomePhabricator

wikistats.py seems broken
Closed, ResolvedPublic

Description

See wikistats_tests:

======================================================================
ERROR: test_sort (tests.wikistats_tests.WikiStatsTestCase)
Test sorted results.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/magul/pywikibot-core/tests/wikistats_tests.py", line 28, in test_sort
    top = data[0]
IndexError: list index out of range

======================================================================
FAIL: test_last_edit (tests.pagegenerators_tests.EdittimeFilterPageGeneratorTestCase)
Test last edit.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/magul/pywikibot-core/tests/pagegenerators_tests.py", line 320, in test_last_edit
    self.assertEqual(len(list(gen)), 1)
AssertionError: 0 != 1

======================================================================
FAIL: test_CategoryFilterPageGenerator (tests.pagegenerators_tests.TestCategoryFilterPageGenerator)
Test CategoryFilterPageGenerator.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/magul/pywikibot-core/tests/pagegenerators_tests.py", line 241, in test_CategoryFilterPageGenerator
    self.assertEqual(len(tuple(gen)), 9)
AssertionError: 10 != 9

======================================================================
FAIL: test_csv (tests.wikistats_tests.WikiStatsTestCase)
Test CSV.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/magul/pywikibot-core/tests/wikistats_tests.py", line 70, in test_csv
    self.assertIn('en', data)
AssertionError: u'en' not found in {}

======================================================================
FAIL: test_xml (tests.wikistats_tests.WikiStatsTestCase)
Test XML.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/magul/pywikibot-core/tests/wikistats_tests.py", line 86, in test_xml
    self.assertIn('en', data)
AssertionError: u'en' not found in {}

----------------------------------------------------------------------
Ran 1472 tests in 420.770s

and

C:\pwb\GIT\core>py -2 pwb.py tests/wikistats_tests
WARNING: C:\pwb\GIT\core\pywikibot\tools\ip.py:74: ImportWarning: Importing ipad
dr.IPAddress failed: No module named ipaddr
Importing ipaddress.ip_address failed: No module named ipaddress
Please install ipaddr 2.1.10+ or ipaddress.
tests: max_retries reduced from 25 to 1
WARNING: WikiStats: unicodecsv package required for using csv in Python 2; falli
ng back to using the larger XML datasets.
sWARNING: Http response status 500
EWARNING: Http response status 500
EWARNING: Http response status 500
E
======================================================================
ERROR: test_sort (__main__.WikiStatsTestCase)
Test sorted results.
----------------------------------------------------------------------
Traceback (most recent call last):
  File ".\tests\wikistats_tests.py", line 27, in test_sort
    data = ws.sorted('wikipedia', 'total')
  File "C:\pwb\GIT\core\pywikibot\data\wikistats.py", line 232, in sorted
    return sorted(self.get(table),
  File "C:\pwb\GIT\core\pywikibot\data\wikistats.py", line 209, in get
    data = self.xml(table)
  File "C:\pwb\GIT\core\pywikibot\data\wikistats.py", line 180, in xml
    tree = cElementTree.parse(f)
  File "<string>", line 62, in parse
  File "<string>", line 38, in parse
ParseError: no element found: line 1, column 0

======================================================================
ERROR: test_sorting_order (__main__.WikiStatsTestCase)
Test sorting order of languages_by_size.
----------------------------------------------------------------------
Traceback (most recent call last):
  File ".\tests\wikistats_tests.py", line 51, in test_sorting_order
    data = ws.get_dict(FAMILY)
  File "C:\pwb\GIT\core\pywikibot\data\wikistats.py", line 223, in get_dict
    for data in self.get(table, format))
  File "C:\pwb\GIT\core\pywikibot\data\wikistats.py", line 209, in get
    data = self.xml(table)
  File "C:\pwb\GIT\core\pywikibot\data\wikistats.py", line 180, in xml
    tree = cElementTree.parse(f)
  File "<string>", line 62, in parse
  File "<string>", line 38, in parse
ParseError: no element found: line 1, column 0

======================================================================
ERROR: test_xml (__main__.WikiStatsTestCase)
Test XML.
----------------------------------------------------------------------
Traceback (most recent call last):
  File ".\tests\wikistats_tests.py", line 84, in test_xml
    data = ws.get_dict('wikisource', 'xml')
  File "C:\pwb\GIT\core\pywikibot\data\wikistats.py", line 223, in get_dict
    for data in self.get(table, format))
  File "C:\pwb\GIT\core\pywikibot\data\wikistats.py", line 209, in get
    data = self.xml(table)
  File "C:\pwb\GIT\core\pywikibot\data\wikistats.py", line 180, in xml
    tree = cElementTree.parse(f)
  File "<string>", line 62, in parse
  File "<string>", line 38, in parse
ParseError: no element found: line 1, column 0

----------------------------------------------------------------------
Ran 4 tests in 2.156s

FAILED (errors=3, skipped=1)

Event Timeline

Might be upstream. xml files aren't available.

project-wikistats:*:50338:jem,robih,southparkfan,marc,novaadmin,mschon,paladox,mah,dzahn,andrew . Seems to be a volunteer project?

Change 354697 had a related patch set uploaded (by Multichill; owner: Multichill):
[pywikibot/core@master] Make the tests pass again: * https://en.wikisource.org/w/index.php?type=revision&diff=6811951&oldid=4889209 made the number of validated pages increase * https://en.wikipedia.org/w/index.php?type=revision&diff=780329438&oldid=780327410 made the edit test

https://gerrit.wikimedia.org/r/354697

I removed the Patch-For-Review tag because the previous patch skips the test but this issue isn't solved.

Change 359653 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [bugfix] Re-enable xml for WikiStats with py2

https://gerrit.wikimedia.org/r/359653

Change 359653 merged by jenkins-bot:
[pywikibot/core@master] [bugfix] Re-enable xml for WikiStats with py2

https://gerrit.wikimedia.org/r/359653