Skip to content

Commit bcd2b4e

Browse files
committed
Integrated pytest with setup.py
1 parent b8e04ca commit bcd2b4e

File tree

21 files changed

+572
-14
lines changed

21 files changed

+572
-14
lines changed

.coverage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
!coverage.py: This is a private format, don't read it directly!{"lines":{"/home/rafael/Documentos/Projetos/pyGmaps/tests/__init__.py":[1],"/home/rafael/Documentos/Projetos/pyGmaps/tests/test_module.py":[1,2,3,5,6,7,10,13,19,25,31,36,41,47,53,61,70,81,93,99,105,111,120,135,143,14,15,16,20,21,22,26,27,28,32,33,37,38,42,43,44,48,49,50,54,55,56,57,58,62,63,64,65,66,67,71,72,73,74,75,76,77,78,82,83,84,85,86,87,88,89,90,94,95,96,100,101,102,106,107,108,112,113,114,115,116,117,121,122,123,125,126,127,129,130,132,136,137,139,140,144,145,146,147,148,149],"/home/rafael/Documentos/Projetos/pyGmaps/pymaps/__init__.py":[1,2,4],"/home/rafael/Documentos/Projetos/pyGmaps/pymaps/pymaps.py":[1,2,3,4,5,7,8,10,11,12,15,16,17,18,21,29,36,37,38,46,61,85,90,117,121,125,141,145,149,153,160,164,192,215,219,227,92,93,155,158,94,147,96,97,99,102,104,105,107,110,112,113,114,115,108,217,194,151,195,119,123,199,156,202,143,203,127,128,129,130,133,139,204,208,209,210,212,22,23,24,25,26,213,220,221,224,225,222,196,131,132,197,134,135,136,137,138,176,178,179,180,181,182,183,39,40,41,47,50,51,53,54,56,57,58,44,161,162],"/home/rafael/Documentos/Projetos/pyGmaps/pymaps/marker.py":[1,2,5,17,18,20,50,72,76,99,100,102,133,21,22,23,24,25,26,27,28,29,67,68,30,31,48,103,104,105,106,107,134,137,108,109,110,112,131],"/home/rafael/Documentos/Projetos/pyGmaps/pymaps/utils.py":[1,4,9,14,27,31,32,33,35,36,28,29,5,6],"/home/rafael/Documentos/Projetos/pyGmaps/pymaps/mapelement.py":[1,2,5,6,11,20,24,32,7,8,9,33,22,12,13,14,15,16,17,18,25,26,29,30,27],"/home/rafael/Documentos/Projetos/pyGmaps/pymaps/templates/template.j2":[1,2,3,5,85,86,6,7,9,10,11,12,13,14,15,16,17,18,19,20,21,23,24,25,27,32,33,34,35,36,37,38,40,45,46,48,49,59,60,65,66,76,77,78,81,82,51,52,54,55,57,58,68,69,71,72,74,75,80,62,63],"/home/rafael/Documentos/Projetos/pyGmaps/setup.py":[]}}
1+
!coverage.py: This is a private format, don't read it directly!{"lines":{"/home/rafael/Documentos/Projetos/pyGmaps/tests/__init__.py":[1],"/home/rafael/Documentos/Projetos/pyGmaps/tests/test_module.py":[1,2,3,4,6,7,8,10,13,16,22,28,34,39,44,50,56,64,73,84,96,102,108,114,123,138,153,168,181,190,17,18,19,23,24,25,29,30,31,35,36,40,41,45,46,47,51,52,53,57,58,59,60,61,65,66,67,68,69,70,74,75,76,77,78,79,80,81,85,86,87,88,89,90,91,92,93,97,98,99,103,104,105,109,110,111,115,116,117,118,119,120,124,125,126,128,129,130,132,133,135,147,149,150,154,169,170,171,172,174,175,177,178,182,183,184,185,186,187,191,192,193,194],"/home/rafael/Documentos/Projetos/pyGmaps/pymaps/__init__.py":[1,2,4],"/home/rafael/Documentos/Projetos/pyGmaps/pymaps/pymaps.py":[1,2,3,4,5,7,8,10,11,12,15,16,17,18,21,29,36,37,38,46,61,85,90,117,121,125,141,145,149,153,160,164,192,215,219,227,92,93,155,158,94,147,96,97,99,102,104,105,107,110,112,113,114,115,108,217,194,151,195,119,123,199,156,202,143,203,127,128,129,130,133,139,204,208,209,210,212,22,23,24,25,26,213,220,221,224,225,222,196,131,132,197,134,135,136,137,138,176,178,179,180,181,182,183,100,185,186,190,39,40,41,47,48,58,44,50,51,53,54,56,57,161,162,229,230,231,233],"/home/rafael/Documentos/Projetos/pyGmaps/pymaps/marker.py":[1,2,5,17,18,20,50,72,76,99,100,102,133,21,22,23,24,25,26,27,28,29,67,68,30,31,48,103,104,105,106,107,134,137,108,109,110,112,131],"/home/rafael/Documentos/Projetos/pyGmaps/pymaps/utils.py":[1,4,9,14,27,31,32,33,35,36,28,29,5,6],"/home/rafael/Documentos/Projetos/pyGmaps/pymaps/mapelement.py":[1,2,5,6,11,20,24,32,7,8,9,33,22,12,13,14,15,16,17,18,25,26,29,30,27],"/home/rafael/Documentos/Projetos/pyGmaps/tests/w3c.py":[1,2,3,4,5,8,17,18,19,20,22,23,24,27],"/home/rafael/Documentos/Projetos/pyGmaps/pymaps/templates/template.j2":[1,2,3,5,85,86,6,7,9,10,11,12,13,14,15,16,17,18,19,20,21,23,24,25,27,32,33,34,35,36,37,38,40,45,46,48,49,59,60,65,66,76,77,78,81,82,51,52,54,55,57,58,68,69,71,72,74,75,80,62,63],"/home/rafael/Documentos/Projetos/pyGmaps/setup.py":[]}}

.eggs/README.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
This directory contains eggs that were downloaded by setuptools to build, test, and run plug-ins.
2+
3+
This directory caches those eggs to prevent repeated downloads.
4+
5+
However, it is safe to delete this directory.
6+
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
.. image:: https://img.shields.io/pypi/v/pytest-runner.svg
2+
:target: https://pypi.org/project/pytest-runner
3+
4+
.. image:: https://img.shields.io/pypi/pyversions/pytest-runner.svg
5+
6+
.. image:: https://img.shields.io/travis/pytest-dev/pytest-runner/master.svg
7+
:target: https://travis-ci.org/pytest-dev/pytest-runner
8+
9+
Setup scripts can use pytest-runner to add setup.py test support for pytest
10+
runner.
11+
12+
Usage
13+
=====
14+
15+
- Add 'pytest-runner' to your 'setup_requires'. Pin to '>=2.0,<3dev' (or
16+
similar) to avoid pulling in incompatible versions.
17+
- Include 'pytest' and any other testing requirements to 'tests_require'.
18+
- Invoke tests with ``setup.py pytest``.
19+
- Pass ``--index-url`` to have test requirements downloaded from an alternate
20+
index URL (unnecessary if specified for easy_install in setup.cfg).
21+
- Pass additional py.test command-line options using ``--addopts``.
22+
- Set permanent options for the ``python setup.py pytest`` command (like ``index-url``)
23+
in the ``[pytest]`` section of ``setup.cfg``.
24+
- Set permanent options for the ``py.test`` run (like ``addopts`` or ``pep8ignore``) in the ``[pytest]``
25+
section of ``pytest.ini`` or ``tox.ini`` or put them in the ``[tool:pytest]``
26+
section of ``setup.cfg``. See `pytest issue 567
27+
<https://github.com/pytest-dev/pytest/issues/567>`_.
28+
- Optionally, set ``test=pytest`` in the ``[aliases]`` section of ``setup.cfg``
29+
to cause ``python setup.py test`` to invoke pytest.
30+
31+
Example
32+
=======
33+
34+
The most simple usage looks like this in setup.py::
35+
36+
setup(
37+
setup_requires=[
38+
'pytest-runner',
39+
],
40+
tests_require=[
41+
'pytest',
42+
],
43+
)
44+
45+
Additional dependencies require to run the tests (e.g. mock or pytest
46+
plugins) may be added to tests_require and will be downloaded and
47+
required by the session before invoking pytest.
48+
49+
Follow `this search on github
50+
<https://github.com/search?utf8=%E2%9C%93&q=filename%3Asetup.py+pytest-runner&type=Code&ref=searchresults>`_
51+
for examples of real-world usage.
52+
53+
Standalone Example
54+
==================
55+
56+
This technique is deprecated - if you have standalone scripts
57+
you wish to invoke with dependencies, `use rwt
58+
<https://pypi.org/project/rwt>`_.
59+
60+
Although ``pytest-runner`` is typically used to add pytest test
61+
runner support to maintained packages, ``pytest-runner`` may
62+
also be used to create standalone tests. Consider `this example
63+
failure <https://gist.github.com/jaraco/d979a558bc0bf2194c23>`_,
64+
reported in `jsonpickle #117
65+
<https://github.com/jsonpickle/jsonpickle/issues/117>`_
66+
or `this MongoDB test
67+
<https://gist.github.com/jaraco/0b9e482f5c0a1300dc9a>`_
68+
demonstrating a technique that works even when dependencies
69+
are required in the test.
70+
71+
Either example file may be cloned or downloaded and simply run on
72+
any system with Python and Setuptools. It will download the
73+
specified dependencies and run the tests. Afterward, the the
74+
cloned directory can be removed and with it all trace of
75+
invoking the test. No other dependencies are needed and no
76+
system configuration is altered.
77+
78+
Then, anyone trying to replicate the failure can do so easily
79+
and with all the power of pytest (rewritten assertions,
80+
rich comparisons, interactive debugging, extensibility through
81+
plugins, etc).
82+
83+
As a result, the communication barrier for describing and
84+
replicating failures is made almost trivially low.
85+
86+
Considerations
87+
==============
88+
89+
Conditional Requirement
90+
-----------------------
91+
92+
Because it uses Setuptools setup_requires, pytest-runner will install itself
93+
on every invocation of setup.py. In some cases, this causes delays for
94+
invocations of setup.py that will never invoke pytest-runner. To help avoid
95+
this contingency, consider requiring pytest-runner only when pytest
96+
is invoked::
97+
98+
needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv)
99+
pytest_runner = ['pytest-runner'] if needs_pytest else []
100+
101+
# ...
102+
103+
setup(
104+
#...
105+
setup_requires=[
106+
#... (other setup requirements)
107+
] + pytest_runner,
108+
)
109+
110+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright Jason R. Coombs
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
Metadata-Version: 2.0
2+
Name: pytest-runner
3+
Version: 4.0
4+
Summary: Invoke py.test as distutils command with dependency resolution
5+
Home-page: https://github.com/pytest-dev/pytest-runner
6+
Author: Jason R. Coombs
7+
Author-email: jaraco@jaraco.com
8+
License: UNKNOWN
9+
Description-Content-Type: UNKNOWN
10+
Platform: UNKNOWN
11+
Classifier: Development Status :: 5 - Production/Stable
12+
Classifier: Intended Audience :: Developers
13+
Classifier: License :: OSI Approved :: MIT License
14+
Classifier: Programming Language :: Python :: 2.7
15+
Classifier: Programming Language :: Python :: 3
16+
Classifier: Framework :: Pytest
17+
Requires-Python: >=2.7,!=3.0,!=3.1
18+
Provides-Extra: docs
19+
Requires-Dist: sphinx; extra == 'docs'
20+
Requires-Dist: jaraco.packaging (>=3.2); extra == 'docs'
21+
Requires-Dist: rst.linker (>=1.9); extra == 'docs'
22+
Provides-Extra: testing
23+
Requires-Dist: pytest (>=2.8); extra == 'testing'
24+
Requires-Dist: pytest-sugar (>=0.9.1); extra == 'testing'
25+
Requires-Dist: collective.checkdocs; extra == 'testing'
26+
Requires-Dist: pytest-virtualenv; extra == 'testing'
27+
28+
.. image:: https://img.shields.io/pypi/v/pytest-runner.svg
29+
:target: https://pypi.org/project/pytest-runner
30+
31+
.. image:: https://img.shields.io/pypi/pyversions/pytest-runner.svg
32+
33+
.. image:: https://img.shields.io/travis/pytest-dev/pytest-runner/master.svg
34+
:target: https://travis-ci.org/pytest-dev/pytest-runner
35+
36+
Setup scripts can use pytest-runner to add setup.py test support for pytest
37+
runner.
38+
39+
Usage
40+
=====
41+
42+
- Add 'pytest-runner' to your 'setup_requires'. Pin to '>=2.0,<3dev' (or
43+
similar) to avoid pulling in incompatible versions.
44+
- Include 'pytest' and any other testing requirements to 'tests_require'.
45+
- Invoke tests with ``setup.py pytest``.
46+
- Pass ``--index-url`` to have test requirements downloaded from an alternate
47+
index URL (unnecessary if specified for easy_install in setup.cfg).
48+
- Pass additional py.test command-line options using ``--addopts``.
49+
- Set permanent options for the ``python setup.py pytest`` command (like ``index-url``)
50+
in the ``[pytest]`` section of ``setup.cfg``.
51+
- Set permanent options for the ``py.test`` run (like ``addopts`` or ``pep8ignore``) in the ``[pytest]``
52+
section of ``pytest.ini`` or ``tox.ini`` or put them in the ``[tool:pytest]``
53+
section of ``setup.cfg``. See `pytest issue 567
54+
<https://github.com/pytest-dev/pytest/issues/567>`_.
55+
- Optionally, set ``test=pytest`` in the ``[aliases]`` section of ``setup.cfg``
56+
to cause ``python setup.py test`` to invoke pytest.
57+
58+
Example
59+
=======
60+
61+
The most simple usage looks like this in setup.py::
62+
63+
setup(
64+
setup_requires=[
65+
'pytest-runner',
66+
],
67+
tests_require=[
68+
'pytest',
69+
],
70+
)
71+
72+
Additional dependencies require to run the tests (e.g. mock or pytest
73+
plugins) may be added to tests_require and will be downloaded and
74+
required by the session before invoking pytest.
75+
76+
Follow `this search on github
77+
<https://github.com/search?utf8=%E2%9C%93&q=filename%3Asetup.py+pytest-runner&type=Code&ref=searchresults>`_
78+
for examples of real-world usage.
79+
80+
Standalone Example
81+
==================
82+
83+
This technique is deprecated - if you have standalone scripts
84+
you wish to invoke with dependencies, `use rwt
85+
<https://pypi.org/project/rwt>`_.
86+
87+
Although ``pytest-runner`` is typically used to add pytest test
88+
runner support to maintained packages, ``pytest-runner`` may
89+
also be used to create standalone tests. Consider `this example
90+
failure <https://gist.github.com/jaraco/d979a558bc0bf2194c23>`_,
91+
reported in `jsonpickle #117
92+
<https://github.com/jsonpickle/jsonpickle/issues/117>`_
93+
or `this MongoDB test
94+
<https://gist.github.com/jaraco/0b9e482f5c0a1300dc9a>`_
95+
demonstrating a technique that works even when dependencies
96+
are required in the test.
97+
98+
Either example file may be cloned or downloaded and simply run on
99+
any system with Python and Setuptools. It will download the
100+
specified dependencies and run the tests. Afterward, the the
101+
cloned directory can be removed and with it all trace of
102+
invoking the test. No other dependencies are needed and no
103+
system configuration is altered.
104+
105+
Then, anyone trying to replicate the failure can do so easily
106+
and with all the power of pytest (rewritten assertions,
107+
rich comparisons, interactive debugging, extensibility through
108+
plugins, etc).
109+
110+
As a result, the communication barrier for describing and
111+
replicating failures is made almost trivially low.
112+
113+
Considerations
114+
==============
115+
116+
Conditional Requirement
117+
-----------------------
118+
119+
Because it uses Setuptools setup_requires, pytest-runner will install itself
120+
on every invocation of setup.py. In some cases, this causes delays for
121+
invocations of setup.py that will never invoke pytest-runner. To help avoid
122+
this contingency, consider requiring pytest-runner only when pytest
123+
is invoked::
124+
125+
needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv)
126+
pytest_runner = ['pytest-runner'] if needs_pytest else []
127+
128+
# ...
129+
130+
setup(
131+
#...
132+
setup_requires=[
133+
#... (other setup requirements)
134+
] + pytest_runner,
135+
)
136+
137+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
ptr.py,sha256=1YXyOGv_PrEL5n1oER7n-JwxAX3ENvlIVPtMFttdCiY,4750
2+
pytest_runner-4.0.dist-info/DESCRIPTION.rst,sha256=3Z1Qbki7q0_at4ej4zkwWC5KLM56qgYlOIPBJapZ61M,3990
3+
pytest_runner-4.0.dist-info/LICENSE.txt,sha256=pV4v_ptEmY5iHVHYwJS-0JrMS1I27nPX3zlaM7o8GP0,1050
4+
pytest_runner-4.0.dist-info/METADATA,sha256=AIapqpb0ymH_JEDuleZdjwS5W44xYFS-LimVZZbFC5g,5023
5+
pytest_runner-4.0.dist-info/RECORD,,
6+
pytest_runner-4.0.dist-info/WHEEL,sha256=kdsN-5OJAZIiHN-iO4Rhl82KyS0bDWf4uBwMbkNafr8,110
7+
pytest_runner-4.0.dist-info/entry_points.txt,sha256=JLlBw8SyLCUnYguY0hs5dVnA9dMbhuEVPnDjojJbXHw,59
8+
pytest_runner-4.0.dist-info/metadata.json,sha256=bAx8itV8zSSs_X_JSRhUuGd1MeAU24-aLK4MI4UtGVk,1143
9+
pytest_runner-4.0.dist-info/namespace_packages.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
10+
pytest_runner-4.0.dist-info/top_level.txt,sha256=DPzHbWlKG8yq8EOD5UgEvVNDWeJRPyimrwfShwV6Iuw,4
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Wheel-Version: 1.0
2+
Generator: bdist_wheel (0.30.0)
3+
Root-Is-Purelib: true
4+
Tag: py2-none-any
5+
Tag: py3-none-any
6+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[distutils.commands]
2+
ptr = ptr:PyTest
3+
pytest = ptr:PyTest
4+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"classifiers": ["Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Framework :: Pytest"], "description_content_type": "UNKNOWN", "extensions": {"python.details": {"contacts": [{"email": "jaraco@jaraco.com", "name": "Jason R. Coombs", "role": "author"}], "document_names": {"description": "DESCRIPTION.rst", "license": "LICENSE.txt"}, "project_urls": {"Home": "https://github.com/pytest-dev/pytest-runner"}}, "python.exports": {"distutils.commands": {"ptr": "ptr:PyTest", "pytest": "ptr:PyTest"}}}, "extras": ["docs", "testing"], "generator": "bdist_wheel (0.30.0)", "metadata_version": "2.0", "name": "pytest-runner", "requires_python": ">=2.7,!=3.0,!=3.1", "run_requires": [{"extra": "testing", "requires": ["collective.checkdocs", "pytest (>=2.8)", "pytest-sugar (>=0.9.1)", "pytest-virtualenv"]}, {"extra": "docs", "requires": ["jaraco.packaging (>=3.2)", "rst.linker (>=1.9)", "sphinx"]}], "summary": "Invoke py.test as distutils command with dependency resolution", "version": "4.0"}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)