Package: jet-test
Installation•Basic Usage•Mastering Verbosity•Custom Fail Conditions•CustomizationJET is a testing library for python aimed at being fast to set up, easy to use and above all pleasing to the eye. Because testing does not have to be a chore to set up, clutter the terminal or ugly to look at.InstallationNoteJET requiresgumto be installed and available on yourPATH.Best way to install jet is through pip:pipinstalljet-testUsageRunning Testsjetrun<option>--all: Run all test modules. Skips initial module selection.--dir: Path to tests directory. Defaults to /tests when not supplied.--files: List of modules to consider instead of entire directory.--quiet: Disable test ouput verbose as they run.--n-jobs: Number of processes to use in parallel when running tests. Defaults to one.--percentage: Whether to show progress as a percentage instead of count.JET searches for thetestsfolder in your working directory and runs all tests that start withtest_*from the modules named as:test_<something>.py. JET starts by prompting you to choose wich modules to run. You can run all of them by selecting "Run All" or use the--allflag, check theruncommand for more options.Reading Reportsjetsee<option>Specific options for theseecommand:--dir: Path to tests directory. Defaults to /tests when not supplied.--doc-width: Width (number of columns collumns) of report doc.--text-width: Width (number of columns collumns) of text blocks in report.--buffer: Number of lines of code to show in the report.All tests that did not conclude with a "pass" can be further inspected. To see a detailed report including, captured standard output, local variables, source code and error description run theseecommand. The report is colapsable as to display as much information as possible without cluttering your terminal.Mastering VerbosityTest RoutinesJET displays the result of each test after it has been run, unless the--quietflag is raised.if it passes: It displays the tests'sdoc. If nodocis available, it shows the test's name.else: Display's the error/warning/failing condition description. If no description is provided, it shows thedocor name of test. This behaviour is specially usefull of a test has more than one failing condition, for example:#tests have to start with test_deftest_example():"""This is the text that will be display if the test passes"""a=1b=2asserta==1,"Text displayed if a is not equal to 1"assertb==2,"Text displayed if b is not equal to 2"Test ModulesJET searches for modules named:test_<something>.pyin thetests/directory (for a different directory use--dir). When prompting the user JET will display "Seomthing" as the module title and the module__doc__as the description. The descripiton will be blank if JET otherwise. For creating a__doc__for a python module add:"""This is a module documentation.It should be the first line in any python module"""#defines all tests belowdeftest_whatever():...Custom Fail ConditionsSuppose you want a test to fail if it's running time exceeds 0.5 seconds. We do that by creating a wrapper that raises a custom error when the condition is failed.deftimebounded(test_function):"""Example wrapper for a custom suport.Throws an error if the wrapped function exceeds a certain amount of time to run"""@wraps(test_function)defwrappee():elapsed=timeit.timeit(test_function,number=1)ifelapsed>0.5:raisePatienceError(f"CUSTOM ERROR: The function called{test_function.__name__}exceded my patience")returnwrappee@timeboundeddeftest_timings_of_calculation():"""The function should not exeed 0.5 seconds."""time.sleep(1)The custom error and description and variables will show up both on the run erbose but also in the error report. This example can easily be expanded to add different and more complex failing conditions such as memory allocation and network usage etc.Further CustomizationsGlobal JET customization options:jet<option><command>--foreground: color (hex, rgb or terminal256) for foreground elements.--background: color (hex, rgb or terminal256) for background.--pass-color: color (hex, rgb or terminal256) for pass tests.--failed-color: color (hex, rgb or terminal256) for failed tests.--error-color: color (hex, rgb or terminal256) for tests that result in errors.--warning-color: color (hex, rgb or terminal256) for tests that throw warnings.