Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
pip._vendor.pyparsing.testing.pyparsing_test.reset_pyparsing_context Class Reference

Public Member Functions

 __init__ (self)
 
 save (self)
 
 restore (self)
 
 copy (self)
 
 __enter__ (self)
 
 __exit__ (self, *args)
 

Protected Attributes

 _save_context
 

Detailed Description

Context manager to be used when writing unit tests that modify pyparsing config values:
- packrat parsing
- bounded recursion parsing
- default whitespace characters.
- default keyword characters
- literal string auto-conversion class
- __diag__ settings

Example::

    with reset_pyparsing_context():
        # test that literals used to construct a grammar are automatically suppressed
        ParserElement.inlineLiteralsUsing(Suppress)

        term = Word(alphas) | Word(nums)
        group = Group('(' + term[...] + ')')

        # assert that the '()' characters are not included in the parsed tokens
        self.assertParseAndCheckList(group, "(abc 123 def)", ['abc', '123', 'def'])

    # after exiting context manager, literals are converted to Literal expressions again

The documentation for this class was generated from the following file: