jenkins-bot has submitted this change and it was merged.
Change subject: [bugfix] Solve pagegeneratrors_tests.TestFactoryGeneratorWikibase tests ......................................................................
[bugfix] Solve pagegeneratrors_tests.TestFactoryGeneratorWikibase tests
- P357 was redirected to P1476. Use the new property ID to solve the KeyError - There was a hidden bug when comparing the WbMonolingualText because value is a basestring and does not have a __dict__ which is used by the WbRepresentation class. Add a new part for WBMonolingualText into Claim.target_equals() to solve it
Bug: T150653 Change-Id: I4a2602d7d27f66615699af90b599a8a0ad623c50 --- M pywikibot/page.py M tests/pagegenerators_tests.py 2 files changed, 7 insertions(+), 2 deletions(-)
Approvals: Dalba: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py index 165e7c8..9c59baf 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -4631,6 +4631,7 @@ - ItemPage ID equality - WbTime year equality - Coordinate equality, regarding precision + - WbMonolingualText text equality - direct equality
@param value: the value to compare with @@ -4662,6 +4663,10 @@ return (abs(self.target.lat - coord_args[0]) <= precision and abs(self.target.lon - coord_args[1]) <= precision)
+ if (isinstance(self.target, pywikibot.WbMonolingualText) and + isinstance(value, basestring)): + return self.target.text == value + return self.target == value
def has_qualifier(self, qualifier_id, target): diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py index 06380ef..6b243ee 100755 --- a/tests/pagegenerators_tests.py +++ b/tests/pagegenerators_tests.py @@ -1007,7 +1007,7 @@ """Test -onlyif without qualifiers.""" gf = pagegenerators.GeneratorFactory(site=self.site) gf.handleArg('-page:Q15745378') - gf.handleArg('-onlyif:P357=International Journal of Minerals, ' + gf.handleArg('-onlyif:P1476=International Journal of Minerals, ' 'Metallurgy, and Materials') gen = gf.getCombinedGenerator() self.assertIsNotNone(gen) @@ -1017,7 +1017,7 @@ """Test -onlyifnot without qualifiers.""" gf = pagegenerators.GeneratorFactory(site=self.site) gf.handleArg('-page:Q15745378') - gf.handleArg('-onlyifnot:P357=International Journal of Minerals, ' + gf.handleArg('-onlyifnot:P1476=International Journal of Minerals, ' 'Metallurgy, and Materials') gen = gf.getCombinedGenerator() self.assertIsNotNone(gen)
pywikibot-commits@lists.wikimedia.org