How to run Scrapy unit tests in Pycharm

I work with Pycharm trying to run unit test tests - and it does not start. Errors for lack of imports, it looks like all import failures. eg.

Import error... "no module named mock" 

What I've done:

  • Get a bonus from github

  • Run pip to install all the dependencies from the requirements. txt

  • With TOX installed, make sure I can run tests using TOX.

  • Configured Pycharm to run tests using py.test

I am working on Ubuntu 14.04, Python 2.7.

+5
source share
1 answer

You need to additionally establish the testing requirements :

 pip install -r tests/requirements.txt # Python 2 pip install -r tests/requirements-py3.txt # Python 3 

This will install the mock package and solve the no module named mock in Python 2 (assuming you install it in the same environment from which you are running the tests).


Note that to run the tests you must use tox (which will also install the missing dependencies from requirements.txt during the test run setup phase):

 tox -- tests/test_loader.py 

(it’s just that all and the tests are executed and passed to me).

FYI, here is my PyCharm configuration for talk runner:

enter image description here

+4
source

All Articles