Installation
- Install Atom Editor
Install the Script package as follows:
a) Launch Atom
b) Press Ctrl + Shift + P , type โinstall packages and themesโ and press Enter to open the package view
c) Find the "script" and install the package
Unit test example test.py
Write unit test and save it as test.py
import unittest class MyTest(unittest.TestCase): def test_pass(self): pass def test_fail(self): call_method_that_does_not_exist() if __name__ == '__main__': unittest.main()
Run unit test
- Now press Ctrl + I to run the Python script ( see documentation )
Console exit
Since unit test test_fail will fail, this will exit to the console:
E. ====================================================================== ERROR: test_fail (__main__.MyTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/Lernkurve/Desktop/PythonDemos/a.py", line 9, in test_fail call_method_that_does_not_exist() NameError: global name 'call_method_that_does_not_exist' is not defined ---------------------------------------------------------------------- Ran 2 tests in 0.000s FAILED (errors=1) [Finished in 0.047s]
source share