Debug Python Unit Tests in Cloud9 IDE

0

Can anyone tell me how to interactively run and debug python unit tests in the Cloud9 IDE?

I would like to run & debug my python unit tests (pytest) in the Cloud9 IDE similar to the same process using the JetBrains Pycharm IDE. Debugging in this context is running single or multiple unit tests, setting breakpoints, stepping though code, examining variables as well as user input expressions.

I've looked at run configurations in Cloud9, but I could find no clear options on how to interactively run & debug unit tests in the Cloud9 IDE.

asked a year ago318 views
1 Answer
0
Accepted Answer

Currently, you cannot integrate "pytest" in Cloud9 IDE as we can in pycharm IDE under default test runner. Having said that, we can still write the "pytest" test and run them manually by using command : python -m pytest -vv <test_file_name>.py

For example please consider below :

"hello.py" - simply has two functions which returns strings "hi" and "bye" -


def hello():

return "hi"

def bye():

return "bye"

Then we write the tests for pytest "test_hello.py" -


from hello import *

def test_hello():

assert "hi" == hello()

def test_hello2():

assert "some" == hello()

def test_bye():

assert "bye" == bye()

Run test : python -m pytest -vv test_hello.py

======== test session starts ==============

platform linux -- Python 3.7.10, pytest-7.1.3, pluggy-1.0.0 -- /usr/bin/python3 cachedir: .pytest_cache rootdir: /home/ec2-user/environment collected 3 items

test_hello.py::test_helo PASSED [ 33%] test_hello.py::test_helo2 FAILED [ 66%] test_hello.py::test_bye PASSED [100%]

=============== FAILURES ==================

_________________ test_helo2 _____________________

def test_helo2():
  assert "some" == helo()

E AssertionError: assert 'some' == 'hi' E - hi E + some

test_hello.py:7: AssertionError

============ short test summary info ================

Additionally, please refer [+} https://www.youtube.com/watch?v=IN4qt-9bMiE for detailed explanation on using pytest in cloud9 environment.

** Please note that third party link are only for reference purpose and AWS doesn't endorse them.

Further, please feel free to raise a case with AWS Premium Support for further assistance.

AWS
SUPPORT ENGINEER
answered a year ago
  • I do run tests with the command line, but the ability to interactively debug tests is a huge downside to using Cloud9 as a primary IDE. The normal debugger in Cloud9 even with all it's faults and issues, still gives important functionality that any IDE should have, if only it could be extended to running & debugging tests.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions