Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wikicode.matches() doesn't handle lower-case page title #302

Open
roysmith opened this issue Mar 13, 2023 · 1 comment
Open

Wikicode.matches() doesn't handle lower-case page title #302

roysmith opened this issue Mar 13, 2023 · 1 comment

Comments

@roysmith
Copy link

mwparserfromhell==0.6.4
Python 3.9.13
MacOS Monterey

test_mainspace_match() passes, but test_talk_match() fails. They should both pass.

import mwparserfromhell as mwp

def test_mainspace_match():
    wikicode = mwp.parse("[[foo]]")
    link = wikicode.filter_wikilinks()[0]
    assert link.title.matches("Foo")

def test_talk_match():
    wikicode = mwp.parse("[[Talk:foo]]")
    link = wikicode.filter_wikilinks()[0]
    assert link.title.matches("Talk:Foo")

Test results:

(dyk-tools) Roys-MBP [temp] pytest test_matches.py
============================================================================= test session starts =============================================================================
platform darwin -- Python 3.9.13, pytest-7.2.0, pluggy-1.0.0
rootdir: /Users/roy/temp
plugins: mock-3.10.0, socket-0.5.1
collected 2 items                                                                                                                                                             

test_matches.py .F                                                                                                                                                      [100%]

================================================================================== FAILURES ===================================================================================
_______________________________________________________________________________ test_talk_match _______________________________________________________________________________

    def test_talk_match():
        wikicode = mwp.parse("[[Talk:foo]]")
        link = wikicode.filter_wikilinks()[0]
>       assert link.title.matches("Talk:Foo")
E       AssertionError: assert False
E        +  where False = <bound method Wikicode.matches of 'Talk:foo'>('Talk:Foo')
E        +    where <bound method Wikicode.matches of 'Talk:foo'> = 'Talk:foo'.matches
E        +      where 'Talk:foo' = '[[Talk:foo]]'.title

test_matches.py:11: AssertionError
=========================================================================== short test summary info ===========================================================================
FAILED test_matches.py::test_talk_match - AssertionError: assert False
========================================================================= 1 failed, 1 passed in 0.05s =========================================================================
@lahwaacz
Copy link
Contributor

lahwaacz commented Mar 14, 2023

mwparserfromhell does not parse the link title. Note that your test actually depends on the wiki configuration (e.g. the namespace prefixes might be different and first-letter case-insensitiveness might be turned off). You can use my helper class from wiki-scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants