def test_get_code():
 s = u('"""a docstring"""\nclass SomeClass(object, mixin):\n    def __init__(self):\n        self.xy = 3.0\n        """statement docstr"""\n    def some_method(self):\n        return 1\n    def yield_method(self):\n        while hasattr(self, \'xy\'):\n            yield True\n        for x in [1, 2]:\n            yield x\n    def empty(self):\n        pass\nclass Empty:\n    pass\nclass WithDocstring:\n    """class docstr"""\n    pass\ndef method_with_docstring():\n    """class docstr"""\n    pass\n')
 assert (ParserWithRecovery(load_grammar(), s).module.get_code() == s)

def test_get_code ( ) : s = u ( '"""a docstring"""\nclass SomeClass(object, mixin):\n    def __init__(self):\n        self.xy = 3.0\n        """statement docstr"""\n    def some_method(self):\n        return 1\n    def yield_method(self):\n        while hasattr(self, \'xy\'):\n            yield True\n        for x in [1, 2]:\n            yield x\n    def empty(self):\n        pass\nclass Empty:\n    pass\nclass WithDocstring:\n    """class docstr"""\n    pass\ndef method_with_docstring():\n    """class docstr"""\n    pass\n' ) assert ( ParserWithRecovery ( load_grammar ( ) , s ) . module . get_code ( ) == s )
use the same code that the parser also generates .