How to use test_systemExit method in green

Best Python code snippet using green

run_all_tests.py

Source:run_all_tests.py Github

copy

Full Screen

1import os2from datetime import datetime3""" the 'test_user_functions.py' is not tested because, at the 30/07/2019, there is nothing to test"""4FILE_LIST_NOSE_TEST = [5 "test_morphology.py",6 "test_projection.py",7 "test_reconstruction.py",8 "test_utilities.py",9 "test_alignment.py",10 "test_filter.py",11 "test_fundamentals.py",12 "test_statistics.py",13 "test_pixel_error.py",14 "test_multi_shc.py",15]16CURRENT_PATH = os.path.dirname(os.path.abspath(__file__))17# in order to be able to run it from pycharm too, we have to specify the whole path of the commands. change them with your own path or set to FALSE and run it from the commandLine18PYCHARM_RUN = True19PYTEST_PATH = "/home/adnan/applications/sphire/v1.1/envs/conda_fresh/bin/" #"/home/adnan/applications/sphire/v1.1/envs/conda_fresh/bin/"20MPI_PATH = "/home/adnan/applications/sphire/v1.1/envs/conda_fresh/bin/" #"/home/adnan/applications/sphire/v1.1/envs/conda_fresh/bin/"21OUTPUTFILE = "ALL_TEST_LOG_FILE"22# it will save the result on the log file. NB: nosetest logs on stderr (see: https://stackoverflow.com/questions/9519717/how-do-i-redirect-the-output-of-nosetests-to-a-textfile)23def main():24 date = str(datetime.now()).split(".")[0].replace(" ", "_").replace(":", "")25 outputfile = OUTPUTFILE + "_" + date + ".txt"26 pytest_path = "" if PYCHARM_RUN is False else PYTEST_PATH27 mpi_path = "" if PYCHARM_RUN is False else MPI_PATH28 print("running 'test_systemExit.py' ...")29 os.system(30 pytest_path31 + "pytest -v "32 + os.path.join(CURRENT_PATH, "test_systemExit.py")33 + " >"34 + os.path.join(CURRENT_PATH, outputfile)35 )36 for f in FILE_LIST_NOSE_TEST:37 print("running '" + f + "' ...")38 os.system(39 mpi_path40 + "mpirun -np 1 nosetests -v "41 + os.path.join(CURRENT_PATH, f)42 + " 2>>"43 + os.path.join(CURRENT_PATH, outputfile)44 )45if __name__ == "__main__":...

Full Screen

Full Screen

test_callback_traceback.py

Source:test_callback_traceback.py Github

copy

Full Screen

1# derived from test_random_things.py2import pytest3from ctypes import *4_rawffi = pytest.importorskip('_rawffi')5#6# This test makes sure the exception types *and* the exception7# value is printed correctly.8@pytest.mark.skipif("sys.flags.inspect")9def test_SystemExit(monkeypatch, capsys):10 """11 When an exception is raised in a ctypes callback function, the C12 code prints a traceback. When SystemExit is raised, the interpreter13 normally exits immediately.14 """15 def callback_func(arg):16 raise SystemExit(42)17 def custom_exit(value):18 raise Exception("<<<exit(%r)>>>" % (value,))19 monkeypatch.setattr(_rawffi, 'exit', custom_exit)20 cb = CFUNCTYPE(c_int, c_int)(callback_func)21 cb2 = cast(cast(cb, c_void_p), CFUNCTYPE(c_int, c_int))22 out, err = capsys.readouterr()23 assert not err24 cb2(0)25 out, err = capsys.readouterr()26 assert err.splitlines()[-1] == "Exception: <<<exit(42)>>>"27 #28 cb = CFUNCTYPE(c_int, c_int)(callback_func)29 cb(0)30 out, err = capsys.readouterr()...

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