2

I am trying to run my whole test suite in PyCharm. All of the test files are in a single folder. I can run the files individually, but when I create a run configuration with 'All in folder' PyCharm is unable to find any tests.

The messages logged are:

C:\Python36\python.exe "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3.2\helpers\pycharm\utrunner.py" C:\Users\John\PycharmProjects\Kojak\tests\_args_separator_.*\.py$ true
Testing started at 14:56 ...

Process finished with exit code 0
Empty test suite. 

I noticed the _args_separator_ in the path, so what is that all about?

I am running under Windows 7 with PyCharm 2016.3 and Python 2.6

6
  • Are you using py.test? Commented Feb 12, 2017 at 6:26
  • I'm just using import unittest, if that answers your question. This is my fourth week working with Python and my first with unittest. I don't use or import py.test to my knowledge. Commented Feb 12, 2017 at 16:42
  • Sorry, I was not clear. In PyCharm in the run configuration, there is the ability to select the test type to run. What type are you running? Commented Feb 12, 2017 at 16:43
  • It looks to be the Unittests type. Under Defaults I see listed Unittests, Doctests, Nosetests, Py.test, and Attests. I am definitely using the Unittests template Commented Feb 12, 2017 at 21:50
  • I use Py.test. Both it and Nosetest will often do a better job of finding your test cases. GL. Commented Feb 12, 2017 at 21:56

4 Answers 4

1

It worked for me if I select Nosetests when creating the Run/Debug Configuration for Python tests. You will also need to pip install nose. (I am running PyCharm 2017.1 but not sure if that is necessary)

Sign up to request clarification or add additional context in comments.

Comments

1

Using the default test configuration did not work for me. The following does run all test files in a test directory.

  1. In the Edit Configurations menu, select the "+" for a new configuration.
  2. Select the Python Tests -> Unittests configuration template.
  3. Enter your test directory in the input for Target and Working directory.
  4. Enter *.py as the Pattern input. This is the key step.
  5. Choose OK Run your new test configuration.

Comments

0

It turns out the solution is to use the latest release of PyCharm (2017.1 EAP at this writing). All of the test files must reside in the same folder; PyCharm will not discover tests in subfolders.

1 Comment

To make tests in subfolder "discoverable" you need to transform that folders into module, just adding a __init__.py file into them.
0

Pycharm set unit test from a sub folder

I had a similar issue. I could not run a unit test if my tests were saved in a sub folder. This fixed the issue.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.