Page MenuHomePhabricator

test_no_qualifiers failing
Closed, ResolvedPublic

Description

As a result of the changes for T89670, test_no_qualifiers now fails, and there is now no way to tell if precision is missing, and it was valid for precision to be None.

======================================================================

ERROR: test_no_qualifiers (tests.pagegenerators_tests.TestItemClaimFilterPageGenerator)
Test ItemClaimFilterPageGenerator on sample page without qualifiers.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/jayvdb/pywikibot-core/tests/pagegenerators_tests.py", line 664, in test_no_qualifiers
    self._simple_claim_test('P625', '21,78', None, True)
  File "/home/travis/build/jayvdb/pywikibot-core/tests/pagegenerators_tests.py", line 617, in _simple_claim_test
    pages = set(gen)
  File "/home/travis/build/jayvdb/pywikibot-core/pywikibot/pagegenerators.py", line 1462, in filter
    if cls.__filter_match(page, prop, claim, qualifiers) and not negate:
  File "/home/travis/build/jayvdb/pywikibot-core/pywikibot/pagegenerators.py", line 1436, in __filter_match
    if page_claim.target_equals(claim):
  File "/home/travis/build/jayvdb/pywikibot-core/pywikibot/page.py", line 4591, in target_equals
    if self.target.precision is not None:
  File "/home/travis/build/jayvdb/pywikibot-core/pywikibot/__init__.py", line 358, in precision
    raise ValueError('No values set for dim or precision')
ValueError: No values set for dim or precision

Event Timeline

jayvdb renamed this task from test_no_qualifiers tailing to test_no_qualifiers failing.Mar 14 2016, 1:43 PM

This is interesting, since $ nosetests -v didn't throw this error when I ran it, but $ nosetests -v tests.pagegenerators_tests actually did.

Anyways, in __init__.py, in the initial documentation of the property precision, it is mentioned that:

When no precision and no self._dim exists, None is returned.

But in the doc string that I wrote for precisionToDim, we went with:

When neither dim nor precision are set, ValueError is thrown.

and I returned ValueErrors in both the functions when both dim and precision were None.

Removing the ValueError there and simply returning a None whenever both precision and dim are None, (along with necessary changes in wikibase_tests) as was the case in the precision property, solves the issue, and returns no errors for $ nosetests -v tests.pagegenerators_tests and $ nosetests -v tests.wikibase_tests.

Change 277277 had a related patch set uploaded (by Darthbhyrava):
Fix: test_no_qualifiers failing due to Coordinate's precisione

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

Change 277277 merged by jenkins-bot:
Fix: test_no_qualifiers failing due to Coordinate's precision

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