forked from erikrose/mediawiki-parser
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow creating more than one instance of the parser, to avoid memoïza…
…tion problems
- Loading branch information
Showing
5 changed files
with
24 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,20 @@ | |
from unittest import TestCase | ||
|
||
|
||
def setup_module(): | ||
from pijnu import makeParser | ||
This comment has been minimized.
Sorry, something went wrong.
erikrose
|
||
mediawikiGrammar = file("mediawiki.pijnu").read() | ||
mediawikiParser = makeParser(mediawikiGrammar) | ||
|
||
class ParserTestCase(TestCase): | ||
def _grammar(self, method_name): | ||
"""Return a full or partial grammar. | ||
method_name -- If truthy, the attribute of the full grammar to return | ||
""" | ||
from raw import parser | ||
from raw import make_parser | ||
This comment has been minimized.
Sorry, something went wrong.
erikrose
|
||
parser = make_parser() | ||
return getattr(parser, method_name) if method_name else parser | ||
|
||
def parsed_equal_string(self, source, result, method_name): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It would be better (faster, more conventional) to put this up at the top. To avoid name collisions, we can do this: