Testing your Python code with PyCharm

Everybody knows that getting used to writing the testing code in parallel with the running code is a good habit. Used wisely, this method helps you define more precisely your code’s intent and find bugs ASAP, thus saving many hours of debugging that would otherwise have been needed in later phases of the software development cycle.

There is a bunch of testing frameworks available for Python which helps you with keeping your code consistent. PyCharm supports most well-known testing frameworks, such as: Attest, Doctest, Nosetest, py.test and of course Unittest.

We have prepared the Creating and running a Python unit test tutorial. From this simple tutorial you’ll learn how PyCharm helps creating and running Python unit tests with a couple of shortcuts. Try it, use it, and do not forget to explore the graphical test runner embedded in PyCharm.

As always, we appreciate your feedback in the comments below or in our forum!

Develop with pleasure!
– PyCharm Team

About Dmitry Filippov

Product Marketing Manager at JetBrains
This entry was posted in Cool Feature. Bookmark the permalink.

6 Responses to Testing your Python code with PyCharm

  1. ivanelson says:

    This IDE should have feature was “Drag” and “Drop” For Python and PyQt.

  2. Cezar says:

    Sadly I’ve never been able to get it to work with django-nose tests

  3. paul harley says:

    In PyCharm 3.4.1, the ‘Find Usages’ and ‘Go To…’ context-menu items don’t work for fixtures. This is quite annoying.

    e.g. given this test (in test.py)
    def test_sale_http_response(self, fixture_create_sale):

  4. paul harley says:

    …Continue from my above post….

    if I right-click on ‘fixture_create_sale’ and select ‘Find Usages’ I am not shown the fixture implementation. It should be easily found as it resides in the contest.py in the same folder as test.py.

    Is there something else I need to do. This seems pretty basic stuff to me, and I am surprised it doesn’t just work.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">