Skip to content

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

Open
@roysmith

Description

@roysmith

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 =========================================================================

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions