pytest plugin to select tests based on attributes similar to the nose-attrib plugin
Project description
.. image:: https://travis-ci.org/AbdealiJK/pytest-attrib.svg?branch=master
:target: https://travis-ci.org/AbdealiJK/pytest-attrib
pytest-attrib
=============
The `pytest-attrib`_ plugin extends py.test with the ability to select tests
based on a criteria rather than just the filename or pytest.marks. For
example, you might want to run only tests that need internet connectivity,
or tests that are slow.
The `pytest.mark <https://pytest.org/latest/mark.html>`__ plugin already
provides a featrure to mark tests and run only the marked tests. This plugin
also allows to run expressions on the attributes of the class, and does not
require the pytest.mark decorator.
It offers features similar to the nose plugin
`nose-attrib <http://nose.readthedocs.io/en/latest/plugins/attrib.html>`__.
Installation
------------
Install the plugin with::
pip install pytest-attrib
Usage examples
--------------
To use the plugin, the ``-a`` CLI argument has been provided. Consider a
project with the test file:
.. code-block:: python
:caption: test_sample.py
import unittest
class MyTestCase(unittest.TestCase):
def test_function(self):
assert 1 == 1
class MySlowTestCase(unittest.TestCase):
slow = True
def test_slow_function(self):
import time
time.sleep(5)
assert 1 == 1
Using pytest-attrib, only the slow tests can be run using::
$ py.test -a slow
Or run only the fast tests using::
$ py.test -a "not slow"
The expression given in the ``-a`` argument can be even more complex, for
example::
$ py.test -a "slow and requires_internet"
$ py.test -a "slow and not requires_internet"
It can also do conditional arguments like::
$ py.test -a "speed=='slow' and requires_internet"
LICENSE
-------
.. image:: https://img.shields.io/github/license/AbdealiJK/pytest-attrib.svg
:target: https://opensource.org/licenses/MIT
This code falls under the
`MIT License <https://tldrlegal.com/license/mit-license>`__.
Please note that some files or content may be copied from other places
and have their own licenses. Dependencies that are being used to generate
the databases also have their own licenses.
:target: https://travis-ci.org/AbdealiJK/pytest-attrib
pytest-attrib
=============
The `pytest-attrib`_ plugin extends py.test with the ability to select tests
based on a criteria rather than just the filename or pytest.marks. For
example, you might want to run only tests that need internet connectivity,
or tests that are slow.
The `pytest.mark <https://pytest.org/latest/mark.html>`__ plugin already
provides a featrure to mark tests and run only the marked tests. This plugin
also allows to run expressions on the attributes of the class, and does not
require the pytest.mark decorator.
It offers features similar to the nose plugin
`nose-attrib <http://nose.readthedocs.io/en/latest/plugins/attrib.html>`__.
Installation
------------
Install the plugin with::
pip install pytest-attrib
Usage examples
--------------
To use the plugin, the ``-a`` CLI argument has been provided. Consider a
project with the test file:
.. code-block:: python
:caption: test_sample.py
import unittest
class MyTestCase(unittest.TestCase):
def test_function(self):
assert 1 == 1
class MySlowTestCase(unittest.TestCase):
slow = True
def test_slow_function(self):
import time
time.sleep(5)
assert 1 == 1
Using pytest-attrib, only the slow tests can be run using::
$ py.test -a slow
Or run only the fast tests using::
$ py.test -a "not slow"
The expression given in the ``-a`` argument can be even more complex, for
example::
$ py.test -a "slow and requires_internet"
$ py.test -a "slow and not requires_internet"
It can also do conditional arguments like::
$ py.test -a "speed=='slow' and requires_internet"
LICENSE
-------
.. image:: https://img.shields.io/github/license/AbdealiJK/pytest-attrib.svg
:target: https://opensource.org/licenses/MIT
This code falls under the
`MIT License <https://tldrlegal.com/license/mit-license>`__.
Please note that some files or content may be copied from other places
and have their own licenses. Dependencies that are being used to generate
the databases also have their own licenses.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pytest-attrib-0.1.tar.gz
(3.2 kB
view details)
Built Distribution
File details
Details for the file pytest-attrib-0.1.tar.gz
.
File metadata
- Download URL: pytest-attrib-0.1.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 811875b0bf97b66db31c1184fa726c86ad9a564dedfd04e6a946a60b3800cb11 |
|
MD5 | e0232991ed4dc0b9450926781e061148 |
|
BLAKE2b-256 | 58038e856ca015e85955f87f03fe827557095acde8c2a3dd774ef4aeb676ec95 |
File details
Details for the file pytest-attrib-0.1.linux-i686.tar.gz
.
File metadata
- Download URL: pytest-attrib-0.1.linux-i686.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23e2353f000d533a7aa10a03796bc778fec88c9c1d94d4a35bf11c9f25dc9a77 |
|
MD5 | 6ea8d030dfe71aa3501fa257fe2ba4e3 |
|
BLAKE2b-256 | 809da75c40d223e43880a3d585927eddf46bc43d3ce0b8f61578f99576e874ce |