Best Python code snippet using Testify_python
doc_controls_test.py
Source:doc_controls_test.py
...25 def test_do_not_doc_on_method(self):26 """The simple decorator is not aware of inheritance."""27 class Parent(object):28 @doc_controls.do_not_generate_docs29 def my_method(self):30 pass31 class Child(Parent):32 def my_method(self):33 pass34 class GrandChild(Child):35 pass36 self.assertTrue(doc_controls.should_skip(Parent.my_method))37 self.assertFalse(doc_controls.should_skip(Child.my_method))38 self.assertFalse(doc_controls.should_skip(GrandChild.my_method))39 self.assertTrue(doc_controls.should_skip_class_attr(Parent, 'my_method'))40 self.assertFalse(doc_controls.should_skip_class_attr(Child, 'my_method'))41 self.assertFalse(42 doc_controls.should_skip_class_attr(GrandChild, 'my_method'))43 def test_do_not_doc_inheritable(self):44 class Parent(object):45 @doc_controls.do_not_doc_inheritable46 def my_method(self):47 pass48 class Child(Parent):49 def my_method(self):50 pass51 class GrandChild(Child):52 pass53 self.assertTrue(doc_controls.should_skip(Parent.my_method))54 self.assertFalse(doc_controls.should_skip(Child.my_method))55 self.assertFalse(doc_controls.should_skip(GrandChild.my_method))56 self.assertTrue(doc_controls.should_skip_class_attr(Parent, 'my_method'))57 self.assertTrue(doc_controls.should_skip_class_attr(Child, 'my_method'))58 self.assertTrue(59 doc_controls.should_skip_class_attr(GrandChild, 'my_method'))60 def test_do_not_doc_inheritable_property(self):61 class Parent(object):62 @property63 @doc_controls.do_not_doc_inheritable64 def my_method(self):65 pass66 class Child(Parent):67 @property68 def my_method(self):69 pass70 class GrandChild(Child):71 pass72 self.assertTrue(doc_controls.should_skip(Parent.my_method))73 self.assertFalse(doc_controls.should_skip(Child.my_method))74 self.assertFalse(doc_controls.should_skip(GrandChild.my_method))75 self.assertTrue(doc_controls.should_skip_class_attr(Parent, 'my_method'))76 self.assertTrue(doc_controls.should_skip_class_attr(Child, 'my_method'))77 self.assertTrue(78 doc_controls.should_skip_class_attr(GrandChild, 'my_method'))79 def test_do_not_doc_inheritable_staticmethod(self):80 class GrandParent(object):81 def my_method(self):82 pass83 class Parent(GrandParent):84 @staticmethod85 @doc_controls.do_not_doc_inheritable86 def my_method():87 pass88 class Child(Parent):89 @staticmethod90 def my_method():91 pass92 class GrandChild(Child):93 pass94 self.assertFalse(doc_controls.should_skip(GrandParent.my_method))95 self.assertTrue(doc_controls.should_skip(Parent.my_method))96 self.assertFalse(doc_controls.should_skip(Child.my_method))97 self.assertFalse(doc_controls.should_skip(GrandChild.my_method))98 self.assertFalse(99 doc_controls.should_skip_class_attr(GrandParent, 'my_method'))100 self.assertTrue(doc_controls.should_skip_class_attr(Parent, 'my_method'))101 self.assertTrue(doc_controls.should_skip_class_attr(Child, 'my_method'))102 self.assertTrue(103 doc_controls.should_skip_class_attr(GrandChild, 'my_method'))104 def test_for_subclass_implementers(self):105 class GrandParent(object):106 def my_method(self):107 pass108 class Parent(GrandParent):109 @doc_controls.for_subclass_implementers110 def my_method(self):111 pass112 class Child(Parent):113 pass114 class GrandChild(Child):115 def my_method(self):116 pass117 class Grand2Child(Child):118 pass119 self.assertFalse(120 doc_controls.should_skip_class_attr(GrandParent, 'my_method'))121 self.assertFalse(doc_controls.should_skip_class_attr(Parent, 'my_method'))122 self.assertTrue(doc_controls.should_skip_class_attr(Child, 'my_method'))123 self.assertTrue(124 doc_controls.should_skip_class_attr(GrandChild, 'my_method'))125 self.assertTrue(126 doc_controls.should_skip_class_attr(Grand2Child, 'my_method'))127 def test_for_subclass_implementers_short_circuit(self):128 class GrandParent(object):129 @doc_controls.for_subclass_implementers130 def my_method(self):131 pass132 class Parent(GrandParent):133 def my_method(self):134 pass135 class Child(Parent):136 @doc_controls.do_not_doc_inheritable137 def my_method(self):138 pass139 class GrandChild(Child):140 @doc_controls.for_subclass_implementers141 def my_method(self):142 pass143 class Grand2Child(Child):144 pass145 self.assertFalse(146 doc_controls.should_skip_class_attr(GrandParent, 'my_method'))147 self.assertTrue(doc_controls.should_skip_class_attr(Parent, 'my_method'))148 self.assertTrue(doc_controls.should_skip_class_attr(Child, 'my_method'))149 self.assertFalse(150 doc_controls.should_skip_class_attr(GrandChild, 'my_method'))151 self.assertTrue(152 doc_controls.should_skip_class_attr(Grand2Child, 'my_method'))153 def test_skip_class_short_circuit(self):154 class GrandParent(object):155 def my_method(self):156 pass157 @doc_controls.do_not_generate_docs158 class Parent(GrandParent):159 pass160 class Child(Parent):161 pass162 self.assertFalse(doc_controls.should_skip(Child))163 self.assertTrue(doc_controls.should_skip(Parent))164 self.assertFalse(doc_controls.should_skip(GrandParent))165 self.assertFalse(166 doc_controls.should_skip_class_attr(GrandParent, 'my_method'))167 self.assertFalse(doc_controls.should_skip_class_attr(Parent, 'my_method'))168 self.assertFalse(doc_controls.should_skip_class_attr(Child, 'my_method'))169 def test_doc_in_current_and_subclasses(self):170 class Parent:171 @doc_controls.do_not_doc_in_subclasses172 def my_method(self):173 pass174 class Child1(Parent):175 @doc_controls.doc_in_current_and_subclasses176 def my_method(self):177 pass178 class Child11(Child1):179 pass180 class Child2(Parent):181 pass182 self.assertFalse(doc_controls.should_skip_class_attr(Parent, 'my_method'))183 self.assertFalse(doc_controls.should_skip_class_attr(Child1, 'my_method'))184 self.assertFalse(doc_controls.should_skip_class_attr(Child11, 'my_method'))185 self.assertTrue(doc_controls.should_skip_class_attr(Child2, 'my_method'))186if __name__ == '__main__':...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!