RubberDuckEE
RubberDuckEE

Reputation: 11

How to fix: Pytest "Create Test" dialog box won't open in Pycharm

I'm trying to follow the tutorial on jetbrains (link: https://www.jetbrains.com/help/pycharm/pytest.html) about using pytest in pycharm so I can work on test driven development. I'm stuck at the part where I'm supposed to create a test for a specific function in the Car.py module (found here: https://www.jetbrains.com/help/pycharm/creating-and-running-your-first-python-project.html#) by hitting ctrl+shift+T and then clicking "Create new test...". Screenshot of the step in the tutorial I'm stuck at.

When I click "Create new test..." nothing happens. The dialog box which is supposed to pop-up does not appear.

I've gone to Settings>Tools>Python Integrated Tools and changed Default test runner to pytest like I'm supposed to. I checked packages in the Project Interpreter and pytest version 5.3.5 is there which I just installed. I restarted pycharm for good measure. Does anyone know why the dialog box might not be appearing? I'm sure there is a more manual approach to making the test file but the built-in pycharm ability to do this quicker/easier is preferable.

Upvotes: 1

Views: 660

Answers (3)

Alex Mandelias
Alex Mandelias

Reputation: 517

Press Ctrl+Alt+S to open the Settings window, go to Project <project name> > Project Structure and mark your source folders as Sources (highlighted as blue in my version of PyCharm). Then you should be able to create tests for them.

Upvotes: 0

Adrian
Adrian

Reputation: 373

Thanks for answering your own question, you have given me an idea for my solution. For what reason so ever, I was not providing PyCharm a root directory for my project so it was not recognising my files. I changed it under:

Preferences > Project:"your project name" > Project Structure

Upvotes: 3

RaviVadera
RaviVadera

Reputation: 411

It was a silly mistake in my case. I was not opening the proper project folder. Instead I was opening parent folder.

My hierarchy was E:\Projects\SampleProject

Instead of opening SampleProject in PyCharm, I was opening Projects directory whole.

I think PyCharm will only open this if it recognizes valid structure of the project.

Upvotes: 2

Related Questions