Don't have 'py.test in ...' in context menu

已回答

Hi all,

Although it is looks like I did everything required for Pycharm to understand that my module contain tests I don't see this option when I right click a tests module or test in a module. I have no unittest option or py.test
 
1. I changed the Default test runner for the project to py.test
2. My module name and test names inside it starts with test
 
My module relative path is: tests/unit/devices/services/test_device_type_service.py
 
What am I missing?
 
Thanks
Guy
1

Hi! Please make sure there's no existing pure Python Run Configuration for this file. By default, PyCharm suggests existed Run Configuration. If this is not the case - please provide a code sample from the test module itself.

0
Avatar
Permanently deleted user

Thank you for your answer Pavel.

My run configuration section is empty(only the defaults).

See below example of my tests 

import json

from mock import patch, MagicMock
from svc.devices.services.device_type import DeviceTypeService


class DaoMock:

def fetch(self, device_type_name=None):
pass

def save(self, instance):
pass

def delete(self, device_type_name):
pass


class TestDeviceTypeService:

path_to_results_file = 'tests/unit/devices/models/dao/resources/device_types.json'

@classmethod
def setup_class(cls):
pass

def test_device_fetch_all(self):
pass

def test_device_fetch_by_name(self):
pass

def test_device_fetch_all_return_none(self):
pass

@patch('svc.devices.services.device_type.DeviceTypeService.fetch')
def test_device_save_new(self, mock_fetch):
pass

@patch('svc.devices.services.device_type.DeviceTypeService.fetch')
def test_device_save_exists(self, mock_fetch):
pass
0

Could you please specify which PyCharm version you are using? There were few related fixes in the latest builds; please check if 2017.3 shows the same behavior.

0
Avatar
Permanently deleted user

I used 2017.2.4 update to latest 2017.3.1 and it looks good.

Will test it for a while and will update.

 

Thanks a lot Pavel

0
Avatar
Permanently deleted user

I switched my test runner from default unitttest to pytest and I had to close and re-open the project so it starts to create pytest run configurations with right click menu

3

请先登录再写评论。