How to use raise_internal_failure method in green

Best Python code snippet using green

process.py

Source:process.py Github

copy

Full Screen

...301 # with eachother. So long as the test doesn't use a hard-coded temp302 # directory, anyway.303 saved_tempdir = tempfile.tempdir304 tempfile.tempdir = tempfile.mkdtemp()305 def raise_internal_failure(msg):306 err = sys.exc_info()307 t = ProtoTest()308 t.module = "green.loader"309 t.class_name = "N/A"310 t.description = msg311 t.method_name = "poolRunner"312 result.startTest(t)313 result.addError(t, err)314 result.stopTest(t)315 queue.put(result)316 cleanup()317 def cleanup():318 # Restore the state of the temp directory319 tempfile.tempdir = saved_tempdir320 queue.put(None)321 # Finish coverage322 if coverage_number:323 cov.stop()324 cov.save()325 # Each pool starts its own coverage, later combined by the main process.326 if coverage_number:327 cov = coverage.coverage(328 data_file=".coverage.{}_{}".format(329 coverage_number, random.randint(0, 10000)330 ),331 omit=omit_patterns,332 config_file=cov_config_file,333 )334 cov._warn_no_data = False335 cov.start()336 # What to do each time an individual test is started337 already_sent = set()338 def start_callback(test):339 # Let the main process know what test we are starting340 test = proto_test(test)341 if test not in already_sent:342 queue.put(test)343 already_sent.add(test)344 def finalize_callback(test_result):345 # Let the main process know what happened with the test run346 queue.put(test_result)347 result = ProtoTestResult(start_callback, finalize_callback)348 test = None349 try:350 loader = GreenTestLoader()351 test = loader.loadTargets(target)352 except:353 raise_internal_failure("Green encountered an error loading the unit test.")354 return355 if getattr(test, "run", False):356 # Loading was successful, lets do this357 try:358 test.run(result)359 # If your class setUpClass(self) method crashes, the test doesn't360 # raise an exception, but it does add an entry to errors. Some361 # other things add entries to errors as well, but they all call the362 # finalize callback.363 if (364 result365 and (not result.finalize_callback_called)366 and getattr(result, "errors", False)367 ):368 queue.put(test)369 queue.put(result)370 except:371 # Some frameworks like testtools record the error AND THEN let it372 # through to crash things. So we only need to manufacture another373 # error if the underlying framework didn't, but either way we don't374 # want to crash.375 if result.errors:376 queue.put(result)377 else:378 try:379 err = sys.exc_info()380 result.startTest(test)381 result.addError(test, err)382 result.stopTest(test)383 queue.put(result)384 except:385 raise_internal_failure(386 "Green encountered an error when running the test."387 )388 return389 else:390 # loadTargets() returned an object without a run() method, probably391 # None392 description = (393 'Test loader returned an un-runnable object. Is "{}" '394 "importable from your current location? Maybe you "395 "forgot an __init__.py in your directory? Unrunnable "396 "object looks like: {} of type {} with dir {}".format(397 target, str(test), type(test), dir(test)398 )399 )...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run green automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful