Pytest tutorial Step 4: Cannot run all tests. "No tests were found"

I saw this post: and the others that show up now that I am writing. I am following the tutorial at When I try to run all tests:

1. It says 'Test: test', not  'pytest in tests'

2. It says 'no tests were found'

3. It created and destroyed a test database. Because it is a Django project? There's no db required for these tests.

4. The tests had run individually as shown in the tutorial video.

5. PyCharm 2020.2 on Ubuntu 18.04

Comment actions Permalink

I notice now that both individual tests do say 'pytest in tests' and both still run independently as expected. They also fire right away (although it seems a lot faster than the 3 seconds the auto test is set for). But the run all tests thing is unchanged from my original post. Don't see an edit / update button here...

Comment actions Permalink


Yes, Django tests behave differently than pytest/unittest.

It does create and destroy the database, unless you override that explicitly:

If something is not working as you expect, feel free to provide code sample and describe the issue in detail.

Comment actions Permalink

The way you said 'Django tests behave differently..' made me wonder if that also meant they are incompatible with pytest, so I did a quick Google search and found a plug-in called 'Django-Pytest'.

1. Is Django-Pytest required to make Pytest work with Django, or is it just a helper?

2. Does it work in PyCharm? Note: I did a search for 'pycharm' on their site and got no hits.

3. Are there special rules, configurations, whatever for using Django-Pytest in Pycharm?

4. I found this: and went to change my settings for a Django project, but as soon as I did, I got a yellow triangle with a black ! in the middle, and the words "cant fnd {0} for {1}". I have no idea what that is supposed to mean, and Googling it was useless. 

I have nevertheless continued to try to use this, and have even more problems:

5. Not found

    (no name '/home/Projects/lifeandtimes/chronicle/tests/' in any of [<Module>])

    Note I ran this test by clicking the green triangle right next to test_freqdist() in!!!


    Process finished with exit code 4

    Assertion failed


6. Syntax error

    E File "/home/malikarumi/Projects/lifeandtimes/chronicle/tests/", line 8
    E assert for k, v in tag_stats:
    E ^
    E SyntaxError: invalid syntax

    How can it detect a syntax error in a function it can't find?!


7. Unresolved reference

I have 6 unresolved references in this test file, all of them to variables used in the source code function being tested. After reading some posts from other users, I decided to just run it and see what happens. So I did, and NONE of these 'unresolved references' came up in the test failure report.


8. The test folder and the source have been added as content roots and source folders.


Comment actions Permalink

Do you mean this by any chance ?

No, PyCharm don't have a specific support for them, but they should work if you run them as regular pytest configurations.


Please sign in to leave a comment.