Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python run test with app installed from pip

Tags:

python

pip

ubuntu

For some of the python apps, if I install them manually, I can run python setup.py test inside the app folder to carry out test scripts. But if I install them through pip, there's only an .egg file in dist-packages, so how should I run their test?

like image 665
Xun Yang Avatar asked Apr 22 '13 10:04

Xun Yang


People also ask

How do I run pip after installing Python?

Ensure you can run pip from the command lineRun python get-pip.py . 2 This will install or upgrade pip. Additionally, it will install setuptools and wheel if they're not installed already. Be cautious if you're using a Python install that's managed by your operating system or another package manager.

Does pip run on Python?

PIP is a package manager for Python packages, or modules if you like. Note: If you have Python version 3.4 or later, PIP is included by default.

How do I check pip in Python?

To check if PIP is already installed on Windows, we should open the command line again, type pip , and press Enter . If PIP is installed, we will receive a long notification explaining the program usage, all the available commands and options.

Can you pip install in a Python script?

Use of a Python script to run pip to install a package is not supported by the Python Packaging Authority (PyPA) for the following reason: Pip is not thread-safe, and is intended to be run as a single process. When run as a thread from within a Python script, pip may affect non-pip code with unexpected results.


1 Answers

I did the following in a virtualenv and was able to run the tests.

$ pip install pyelasticsearch
$ pip install nose virtualenv scripttest mock
$ cdsitepackages #virtualenvwrapper shortcut to go to the site-packages directory
$ cd pyelasticsearch/tests
$ nosetests

Depending on where your site-packages directory is located you'll probably replace cdsitepackages with something else. As @thaven mentioned, there are two directories created - one that pyelasticsearch-0.5-py2.7.egg-info/ and one that is pyelasticsearch. If the pyelasticsearch package wasn't actually there, you wouldn't be able to import anything.

like image 141
Jacinda Avatar answered Oct 19 '22 18:10

Jacinda