omer schleifer
omer schleifer

Reputation: 3935

How to run Scrapy unit tests in Pycharm

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 .

Upvotes: 5

Views: 584

Answers (1)

alecxe
alecxe

Reputation: 473993

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

Upvotes: 4

Related Questions