Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting empty test suite when running with pytest from pycharm

I'm having issues with running pytest tests from inside PyCharm

I have a file x_tests.py inside a folder called agents_automation_2 in C:\Temp, the content of the file is

import pytest
def test_mytest():
    assert  False

When I run I get the following output

C:\Python36-32\python.exe "C:\Program Files\JetBrains\PyCharm 2017.3.2\helpers\pycharm_jb_pytest_runner.py" --path C:/Temp/agents_automation_2 Launching py.test with arguments C:/Temp/agents_automation_2 in C:\Temp\agents_automation_2 ============================= test session starts ============================= platform win32 -- Python 3.6.4, pytest-3.4.2, py-1.5.2, pluggy-0.6.0 rootdir: C:\Temp\agents_automation_2, inifile: plugins: xdist-1.22.0, forked-0.2 collected 0 items ======================== no tests ran in 0.01 seconds =========================

However, when I run from a regular windows command line inside the folder the test runs OK

Any idea of what might be the issue ?

Thanks !!!

like image 518
David Fliguer Avatar asked Mar 19 '18 16:03

David Fliguer


People also ask

Why is pytest not running?

To determine why tests are not running, these steps are useful: Verify that all files with test cases start with 'test_' word. Verify that all test cases names also start with 'test_' word. Verify that you have created pytest.

How do I run single pytest in PyCharm?

PyCharm makes it easy to select just one test to run. In fact, there are several ways to do it: With the cursor anywhere in the test you want to focus on, right-click and choose to run that in the test runner. Right-click on the test in the test tool listing and choose to run it.


1 Answers

In my case, test class contains init method, cause empty suite as well. What you need to do is to avoid to write init method.

like image 175
Leo Liang Avatar answered Sep 21 '22 05:09

Leo Liang