Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Scrapy unit tests in Pycharm

Tags:

I am working with Pycharm, trying to run scrapy unit tests - and it fails to run. The errors are for missing imports, seems like all imports are failing. e.g.

 Import error... "no module named mock"

what I did:

  1. Get scrapy from github

  2. Run pip to install all dependencies from requirements.txt

  3. Installed TOX , made sure I can run the tests using TOX.

  4. Configured Pycharm to run tests using py.test

I'm working on Ubuntu 14.04, Python 2.7 .

like image 699
omer schleifer Avatar asked Sep 11 '16 11:09

omer schleifer


1 Answers

You need to additionally pip install the tests requirements:

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

That would install the mock package and solve the no module named mock on Python 2 (assuming you are installing into the same environment, you are running tests from).


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

tox -- tests/test_loader.py

(just done all of that and the tests are running and passing for me).

FYI, here is my PyCharm configuration for the tox runner:

enter image description here

like image 93
alecxe Avatar answered Sep 22 '22 16:09

alecxe