elisa.core.pattern_matcher.PatternMatcher matches things it shouldn't

Bug #251129 reported by Guillaume Emont
4
Affects Status Importance Assigned to Milestone
Moovida
Fix Released
Undecided
Guillaume Emont

Bug Description

The match should do exact match, and not search.

Example code that fails:

from elisa.core.pattern_matcher import PatternMatcher, MatchNotFound

def do_test():
    result = False
    matcher = PatternMatcher()
    matcher.add_pattern("foo", False)
    try:
        result = matcher.match("foobar")
    except MatchNotFound:
        result = True

    return result

Expected behaviour: do_test() returns True.
Current behaviour: do_test() returns False.

To Verify:
1) Install elisa
2) run trial.py elisa-core\elisa\core\tests\test_pattern_matcher.py
3) test_no_wide_match, passes

Revision history for this message
Guillaume Emont (guijemont) wrote :

I need to fix this to be able to do #232574 (DVD).

Changed in elisa:
assignee: nobody → guijemont
status: New → In Progress
Revision history for this message
Michał Sawicz (saviq) wrote :

Guillaume, are you sure that's how it is?

Based on the code attached if matcher.match throws MatchNotFound you catch the exception, set result to True and return it...

Isn't that why it returns True?

Revision history for this message
Guillaume Emont (guijemont) wrote :

I'm pretty sure. The expected behaviour is that match() throws MatchNotFound in that case.
Here's a more clever and simpler version of the test:

def do_test():
    matcher = PatternMatcher()
    matcher.add_pattern("foo", False)
    try:
        matcher.match("foobar")
    except MatchNotFound:
        return True

    return False

Changed in elisa:
status: In Progress → Fix Committed
milestone: none → 0.5.3
Joshua Eichen (jeichen)
description: updated
Changed in elisa:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.