Best Python code snippet using green
test.py
Source:test.py
...142 t2.addChild(iterate)143 except author.ParentExistsError, err:144 print "Good, we expected to get an exception for adding a iterate "\145 "to two parents: %s" % str(err)146def test_bad_attr():147 """This test verifies that an exception is raised when trying to set148 an invalid attribute.149 """150 job = author.Job()151 try:152 job.title = "okay to set title"153 job.foo = "not okay to set foo"154 except AttributeError, err:155 print "Good, we expected to get an exception for setting an invalid "\156 "attribute: %s" % str(err)157def test_spool():158 """This tests the spool method on a job."""159 job = author.Job(160 title="two layer job", priority=10,161 after=datetime.datetime(2012, 12, 14, 16, 24, 5))162 compTask = job.newTask(163 title="comp", argv="comp fg.tif bg.tif out.tif", service="pixarRender")164 fgTask = compTask.newTask(165 title="render fg", argv="prman foreground.rib", service="pixarRender")166 bgTask = compTask.newTask(167 title="render bg", argv="prman foreground.rib", service="pixarRender")168 setEngineClientParam(port=8080)169 job.spool()170def test_postscript():171 """This builds a job with varios postscript commands. Submit the172 job to ensure that only the "none", "always", and "done"173 postscript commands run.174 """175 job = author.Job(title="Test Postscript Done")176 job.newTask(title="sleep", argv="sleep 1", service="pixarRender")177 job.newPostscript(argv="touch /tmp/postscript.none.%j", service="pixarRender")178 job.newPostscript(argv="touch /tmp/postscript.done.%j", when="done", service="pixarRender")179 job.newPostscript(argv="touch /tmp/postscript.error.%j", when="error", service="pixarRender")180 job.newPostscript(argv="touch /tmp/postscript.always.%j", when="always", service="pixarRender")181 try:182 job.newPostscript(argv="touch /tmp/postscript.always.%j", when="nope")183 except TypeError, err:184 print "Good, we caught an invalid value for when: %s" % str(err)185 print job.asTcl()186 187def test_postscript_error():188 """This builds a job with varios postscript commands. Submit the189 job to ensure that only the "none", "always", and "error"190 postscript commands run.191 """192 job = author.Job(title="Test Postscript Error")193 job.newTask(title="fail", argv="/bin/false", service="pixarRender")194 job.newPostscript(argv="touch /tmp/postscript.none.%j", service="pixarRender")195 job.newPostscript(argv="touch /tmp/postscript.done.%j", when="done", service="pixarRender")196 job.newPostscript(argv="touch /tmp/postscript.error.%j", when="error", service="pixarRender")197 job.newPostscript(argv="touch /tmp/postscript.always.%j", when="always", service="pixarRender")198 try:199 job.newPostscript(argv="touch /tmp/postscript.always.%j", when="nope")200 except TypeError, err:201 print "Good, we caught an invalid value for when: %s" % str(err)202 print job.asTcl()203 204if __name__ == "__main__":205 """Run tests."""206 test_short()207 test_long()208 test_all()209 test_instance()210 test_double_add()211 test_bad_attr()212 test_postscript()213 test_postscript_error()...
test_utils.py
Source:test_utils.py
...14 self.assertRaises(AssertionError, import_from_string, "Listener")15 self.assertRaises(AssertionError, import_from_string, ":Listener")16 def test_bad_module(self) -> None:17 self.assertRaises(ModuleNotFoundError, import_from_string, "bad_module:Listener")18 def test_bad_attr(self) -> None:19 self.assertRaises(AttributeError, import_from_string, "tiny_listener:bad_attr")...
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!!