Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install py.test?

So I am new to Python. This may be a very foolish question, but I have no idea how to install packages as pytest?

It would be great if somebody could give instructions in order to achieve this.

like image 663
tazeunite00 Avatar asked Jan 15 '14 23:01

tazeunite00


People also ask

How do I run test PY?

If you're using the PyCharm IDE, you can run unittest or pytest by following these steps: In the Project tool window, select the tests directory. On the context menu, choose the run command for unittest . For example, choose Run 'Unittests in my Tests…'.

What is PY test file?

Pytest is a testing framework based on python. It is mainly used to write API test cases. This tutorial helps you understand − Installation of pytest. Various concepts and features of pytest.


2 Answers

In general, installing a package in Python is pretty simple if you use pip which is already installed if you're using Python 2 >=2.7.9 or Python 3 >=3.4.

In order to install pytest:

Python 2: $ pip install pytest

Python 3: $ pip3 install pytest

However, it is a good practice to isolate Python environments by creating a virtual environment. In order to install pytest in an isolated virtual environment:

Python 2

$ pip install -U virtualenv
$ python -m virtualenv venv
$ source venv/bin/activate # in Windows -> $ venv\Scripts\activate.bat
$ pip install pytest

Python 3

$ pip3 install -U virtualenv
$ python3 -m virtualenv venv
$ source venv/bin/activate # in Windows -> $ venv\Scripts\activate.bat
$ pip install pytest

Python 3.6+

$ python3 -m venv venv
$ source venv/bin/activate # in Windows -> $ venv\Scripts\activate.bat
$ pip install pytest
like image 193
lmiguelvargasf Avatar answered Oct 13 '22 11:10

lmiguelvargasf


Maybe you're looking for something like pip.

For example, if you want to install Cherrypy you must to run

    pip install cherrypy

or if you're using python3, and depending of your distro, the command is

    pip3 install cherrypy

If you're downloading a package from source, then you must to uncompress it and normally, depending the package, you must to run (as administrator or root)

    python setup.py install
like image 42
Orlando Avatar answered Oct 13 '22 10:10

Orlando