I'm trying out the Atom editor and was wondering how I can run Python unit tests with a keyboard shortcut.
Now run your Python script. If you are running Atom on Windows, type Shift-Ctrl B on the keyboard (hold down Shift and Ctrl and then type B). If you are on the Mac, type command-i (hold down the command key and then the letter i). In either case, you should see hello Atom!
Code Execution in Atom Python Generally, we use the command prompt or terminal to execute Python programs. However, Atom provides a plugin known as platformio-ide-terminal in order to execute the python code. We can set up this plugin by navigating to the File in the Menu bar. Go to Settings.
Installation
Install the Script package like this:
a) Start Atom
b) Press Ctrl+Shift+P, type "install packages and themes" and press Enter to open the package view
c) Search for "script" and install the package
Unit test example test.py
Write a 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
Console output
Because the unit test test_fail
will fail, this will be the console output:
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]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With