Page MenuHomePhabricator

wikistats_tests fails
Closed, ResolvedPublic

Description

since few days

C:\>cd pwb/git/core

C:\pwb\GIT\core>py -3 pwb.py wikistats_tests -v
tests: max_retries reduced from 15 to 1
test_csv (__main__.WikiStatsTestCase)
Test CSV. ... ok
test_sort (__main__.WikiStatsTestCase)
Test sorted results. ... ERROR
test_sorting_order (__main__.WikiStatsTestCase)
Test sorting order of languages_by_size. ... ERROR
test_xml (__main__.WikiStatsTestCase)
Test XML. ... ok

======================================================================
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 229, in sorted
    return sorted(self.get(table),
  File "C:\pwb\GIT\core\pywikibot\data\wikistats.py", line 230, in <lambda>
    key=lambda d: int(d[key]),
ValueError: invalid literal for int() with base 10: ''

======================================================================
ERROR: test_sorting_order (__main__.WikiStatsTestCase)
Test sorting order of languages_by_size.
----------------------------------------------------------------------
Traceback (most recent call last):
  File ".\tests\wikistats_tests.py", line 55, in test_sorting_order
    curr = int(data[code]['good'])
ValueError: invalid literal for int() with base 10: ''

----------------------------------------------------------------------
Ran 4 tests in 2.593s

FAILED (errors=2)

C:\pwb\GIT\core>

Event Timeline

Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald Transcript
Xqt triaged this task as High priority.May 19 2020, 7:54 AM

The reason of that failure is the follwing wikipedia table entry:

{'activeusers': '',
 'admins': '',
 'edits': '',
 'good': '',
 'http': '302',
 'id': '332',
 'images': '',
 'lang': 'Awadhi',
 'loclang': '&#x10e5;&#x10d0;&#x10e0;&#x10d7;&#x10e3;&#x10da;&#x10d8;',
 'loclanglink': '',
 'method': '8',
 'prefix': 'awa',
 'ratio': '',
 'si_articlepath': '',
 'si_base': '',
 'si_case': '',
 'si_dbtype': '',
 'si_dbversion': '',
 'si_fallback8bitEncoding': '',
 'si_generator': '',
 'si_lang': '',
 'si_mainpage': '',
 'si_phpsapi': '',
 'si_phpversion': '',
 'si_rev': '',
 'si_rights': '',
 'si_script': '',
 'si_scriptpath': '',
 'si_server': '',
 'si_sitename': '',
 'si_time': '',
 'si_timeoffset': '',
 'si_timezone': '',
 'si_variantarticlepath': '',
 'si_wikiid': '',
 'si_writeapi': '',
 'status': '',
 'total': '',
 'ts': '2020-05-15 12:51:29',
 'users': '',
 'version': '',
 'views': ''}

The problem is 'total': '' where a number is expected.

As shown here the awa wiki entry is mostly empty. Might be the reason is that awa.wikipedia.org is redirected to incubator.

I did not even know "wikistats_tests" is a thing.

Though i can guess the reason for this is that the first time i added a wiki to the stats table before it was actually created.

See T252869#6140154 and the comment from Andre before that. So i guess the answer is to not do this again in the future before wikis are actually created (T251371).

Do you want me to just delete it again from the stats table and add it again later? Or simply wait for the wiki creation to be finished?

I could also just set "total" to 0 manually for now so that it has a number.

I did the latter and set total= and good= to 0 in the db. Did that fix it, @Xqt?

Change 597226 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [bugfix] Assume 0 for empty table contents

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

@Dzahn: The tests works again. Thanks for this quick patch.

Xqt edited projects, added Upstream; removed Patch-For-Review.

Solved upstream