def test_process_all_with_class(): class MyClass(object): def px_fn1(self): "r: g1 g2?" def p_skip_me(self): "r: g1 g2?" def skip_me(self): "r: g1 g2?" px_skip_me = "r: g1 g2?" old_skip_me = MyClass.skip_me old_p_skip_me = MyClass.p_skip_me old_px_skip_me = MyClass.px_skip_me process_all(MyClass) assert hasattr(MyClass, 'skip_me') assert hasattr(MyClass, 'p_skip_me') assert MyClass.skip_me == old_skip_me assert MyClass.p_skip_me == old_p_skip_me assert MyClass.px_skip_me == old_px_skip_me assert hasattr(MyClass, 'p_px_fn1_0') assert hasattr(MyClass, 'p_px_fn1_1')
def test_exception_when_no_docstring(): def px_fn(): pass globals_ = { 'px_fn': px_fn } exception_raised = False try: process_all(globals_) except NoDocstringError: exception_raised = True assert exception_raised
def test_process_all(): def px_fn1(): "r: g1 g2?" def p_skip_me(): "r: g1 g2?" def skip_me(): "r: g1 g2?" globals_ = {'px_fn1': px_fn1, 'p_skip_me': p_skip_me, 'skip_me': skip_me} process_all(globals_) assert_eq(len(globals_), 4) assert 'skip_me' in globals_ assert 'p_skip_me' in globals_ assert globals_['skip_me'] is skip_me assert globals_['p_skip_me'] is p_skip_me assert 'p_px_fn1_0' in globals_ assert 'p_px_fn1_1' in globals_
def test_process_all_with_class(): class MyClass(object): def px_fn1(self): "r: g1 g2?" def p_skip_me(self): "r: g1 g2?" def skip_me(self): "r: g1 g2?" px_skip_me = "r: g1 g2?" old_skip_me = MyClass.skip_me old_p_skip_me = MyClass.p_skip_me old_px_skip_me = MyClass.px_skip_me process_all(MyClass) assert hasattr(MyClass, 'skip_me') assert hasattr(MyClass, 'p_skip_me') # Must use == to compare the methods instead of 'is' for some reason assert MyClass.skip_me == old_skip_me assert MyClass.p_skip_me == old_p_skip_me assert MyClass.px_skip_me == old_px_skip_me assert hasattr(MyClass, 'p_px_fn1_0') assert hasattr(MyClass, 'p_px_fn1_1')
def parse(self, text): easyply.process_all(self) self.parser = yacc.yacc(module=self) return self.parser.parse(text)