Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e57e72f
commit bb40cc1
Showing
10 changed files
with
333 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Config file for automatic testing at travis-ci.org | ||
|
||
sudo: false | ||
language: python | ||
|
||
matrix: | ||
include: | ||
- python: 2.7 | ||
env: TOX_ENV=py27 | ||
- python: 3.4 | ||
env: TOX_ENV=py34 | ||
- python: 3.5 | ||
env: TOX_ENV=py35 | ||
- python: 3.6 | ||
env: TOX_ENV=py36 | ||
- python: 3.7 | ||
env: TOX_ENV=py37 | ||
- python: pypy | ||
env: TOX_ENV=pypy | ||
- python: 3.6 | ||
env: TOX_ENV=flake8 | ||
|
||
install: | ||
- pip install tox | ||
|
||
script: | ||
- tox -e $TOX_ENV | ||
|
||
before_cache: | ||
- rm -rf $HOME/.cache/pip/log | ||
|
||
cache: | ||
directories: | ||
- $HOME/.cache/pip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
The MIT License (MIT) | ||
|
||
Copyright (c) 2019 Bruno Oliveira | ||
|
||
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: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
include LICENSE | ||
include README.rst | ||
|
||
recursive-exclude * __pycache__ | ||
recursive-exclude * *.py[co] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
=============== | ||
pytest-subtests | ||
=============== | ||
|
||
.. image:: https://img.shields.io/pypi/v/pytest-subtests.svg | ||
:target: https://pypi.org/project/pytest-subtests | ||
:alt: PyPI version | ||
|
||
.. image:: https://img.shields.io/pypi/pyversions/pytest-subtests.svg | ||
:target: https://pypi.org/project/pytest-subtests | ||
:alt: Python versions | ||
|
||
.. image:: https://travis-ci.org/nicoddemus/pytest-subtests.svg?branch=master | ||
:target: https://travis-ci.org/nicoddemus/pytest-subtests | ||
:alt: See Build Status on Travis CI | ||
|
||
.. image:: https://ci.appveyor.com/api/projects/status/github/nicoddemus/pytest-subtests?branch=master | ||
:target: https://ci.appveyor.com/project/nicoddemus/pytest-subtests/branch/master | ||
:alt: See Build Status on AppVeyor | ||
|
||
unittest subTest() support and subtests fixture | ||
|
||
---- | ||
|
||
This `pytest`_ plugin was generated with `Cookiecutter`_ along with `@hackebrot`_'s `cookiecutter-pytest-plugin`_ template. | ||
|
||
|
||
Features | ||
-------- | ||
|
||
* TODO | ||
|
||
|
||
Requirements | ||
------------ | ||
|
||
* TODO | ||
|
||
|
||
Installation | ||
------------ | ||
|
||
You can install "pytest-subtests" via `pip`_ from `PyPI`_:: | ||
|
||
$ pip install pytest-subtests | ||
|
||
|
||
Usage | ||
----- | ||
|
||
* TODO | ||
|
||
Contributing | ||
------------ | ||
Contributions are very welcome. Tests can be run with `tox`_, please ensure | ||
the coverage at least stays the same before you submit a pull request. | ||
|
||
License | ||
------- | ||
|
||
Distributed under the terms of the `MIT`_ license, "pytest-subtests" is free and open source software | ||
|
||
|
||
Issues | ||
------ | ||
|
||
If you encounter any problems, please `file an issue`_ along with a detailed description. | ||
|
||
.. _`Cookiecutter`: https://github.com/audreyr/cookiecutter | ||
.. _`@hackebrot`: https://github.com/hackebrot | ||
.. _`MIT`: http://opensource.org/licenses/MIT | ||
.. _`BSD-3`: http://opensource.org/licenses/BSD-3-Clause | ||
.. _`GNU GPL v3.0`: http://www.gnu.org/licenses/gpl-3.0.txt | ||
.. _`Apache Software License 2.0`: http://www.apache.org/licenses/LICENSE-2.0 | ||
.. _`cookiecutter-pytest-plugin`: https://github.com/pytest-dev/cookiecutter-pytest-plugin | ||
.. _`file an issue`: https://github.com/nicoddemus/pytest-subtests/issues | ||
.. _`pytest`: https://github.com/pytest-dev/pytest | ||
.. _`tox`: https://tox.readthedocs.io/en/latest/ | ||
.. _`pip`: https://pypi.org/project/pip/ | ||
.. _`PyPI`: https://pypi.org/project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# What Python version is installed where: | ||
# http://www.appveyor.com/docs/installed-software#python | ||
|
||
environment: | ||
matrix: | ||
- PYTHON: "C:\\Python27" | ||
TOX_ENV: "py27" | ||
|
||
- PYTHON: "C:\\Python34" | ||
TOX_ENV: "py34" | ||
|
||
- PYTHON: "C:\\Python35" | ||
TOX_ENV: "py35" | ||
|
||
- PYTHON: "C:\\Python36" | ||
TOX_ENV: "py36" | ||
|
||
- PYTHON: "C:\\Python37" | ||
TOX_ENV: "py37" | ||
|
||
init: | ||
- "%PYTHON%/python -V" | ||
- "%PYTHON%/python -c \"import struct;print( 8 * struct.calcsize(\'P\'))\"" | ||
|
||
install: | ||
- "%PYTHON%/Scripts/easy_install -U pip" | ||
- "%PYTHON%/Scripts/pip install tox" | ||
- "%PYTHON%/Scripts/pip install wheel" | ||
|
||
build: false # Not a C# project, build stuff at the test step instead. | ||
|
||
test_script: | ||
- "%PYTHON%/Scripts/tox -e %TOX_ENV%" | ||
|
||
after_test: | ||
- "%PYTHON%/python setup.py bdist_wheel" | ||
- ps: "ls dist" | ||
|
||
artifacts: | ||
- path: dist\* | ||
|
||
#on_success: | ||
# - TODO: upload the content of dist/*.whl to a public wheelhouse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import pytest | ||
|
||
|
||
def pytest_addoption(parser): | ||
group = parser.getgroup('subtests') | ||
group.addoption( | ||
'--foo', | ||
action='store', | ||
dest='dest_foo', | ||
default='2019', | ||
help='Set the value for the fixture "bar".' | ||
) | ||
|
||
parser.addini('HELLO', 'Dummy pytest.ini setting') | ||
|
||
|
||
@pytest.fixture | ||
def bar(request): | ||
return request.config.option.dest_foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import os | ||
import codecs | ||
from setuptools import setup | ||
|
||
|
||
def read(fname): | ||
file_path = os.path.join(os.path.dirname(__file__), fname) | ||
return codecs.open(file_path, encoding='utf-8').read() | ||
|
||
|
||
setup( | ||
name='pytest-subtests', | ||
version='0.1.0', | ||
author='Bruno Oliveira', | ||
author_email='nicoddemus@gmail.com', | ||
maintainer='Bruno Oliveira', | ||
maintainer_email='nicoddemus@gmail.com', | ||
license='MIT', | ||
url='https://github.com/nicoddemus/pytest-subtests', | ||
description='unittest subTest() support and subtests fixture', | ||
long_description=read('README.rst'), | ||
py_modules=['pytest_subtests'], | ||
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*', | ||
install_requires=['pytest>=4.4.0'], | ||
classifiers=[ | ||
'Development Status :: 4 - Beta', | ||
'Framework :: Pytest', | ||
'Intended Audience :: Developers', | ||
'Topic :: Software Development :: Testing', | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 2', | ||
'Programming Language :: Python :: 2.7', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3.4', | ||
'Programming Language :: Python :: 3.5', | ||
'Programming Language :: Python :: 3.6', | ||
'Programming Language :: Python :: 3.7', | ||
'Programming Language :: Python :: Implementation :: CPython', | ||
'Programming Language :: Python :: Implementation :: PyPy', | ||
'Operating System :: OS Independent', | ||
'License :: OSI Approved :: MIT License', | ||
], | ||
entry_points={ | ||
'pytest11': [ | ||
'subtests = pytest_subtests', | ||
], | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pytest_plugins = 'pytester' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
|
||
def test_bar_fixture(testdir): | ||
"""Make sure that pytest accepts our fixture.""" | ||
|
||
# create a temporary pytest test module | ||
testdir.makepyfile(""" | ||
def test_sth(bar): | ||
assert bar == "europython2015" | ||
""") | ||
|
||
# run pytest with the following cmd args | ||
result = testdir.runpytest( | ||
'--foo=europython2015', | ||
'-v' | ||
) | ||
|
||
# fnmatch_lines does an assertion internally | ||
result.stdout.fnmatch_lines([ | ||
'*::test_sth PASSED*', | ||
]) | ||
|
||
# make sure that that we get a '0' exit code for the testsuite | ||
assert result.ret == 0 | ||
|
||
|
||
def test_help_message(testdir): | ||
result = testdir.runpytest( | ||
'--help', | ||
) | ||
# fnmatch_lines does an assertion internally | ||
result.stdout.fnmatch_lines([ | ||
'subtests:', | ||
'*--foo=DEST_FOO*Set the value for the fixture "bar".', | ||
]) | ||
|
||
|
||
def test_hello_ini_setting(testdir): | ||
testdir.makeini(""" | ||
[pytest] | ||
HELLO = world | ||
""") | ||
|
||
testdir.makepyfile(""" | ||
import pytest | ||
@pytest.fixture | ||
def hello(request): | ||
return request.config.getini('HELLO') | ||
def test_hello_world(hello): | ||
assert hello == 'world' | ||
""") | ||
|
||
result = testdir.runpytest('-v') | ||
|
||
# fnmatch_lines does an assertion internally | ||
result.stdout.fnmatch_lines([ | ||
'*::test_hello_world PASSED*', | ||
]) | ||
|
||
# make sure that that we get a '0' exit code for the testsuite | ||
assert result.ret == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# For more information about tox, see https://tox.readthedocs.io/en/latest/ | ||
[tox] | ||
envlist = py27,py34,py35,py36,py37,pypy,flake8 | ||
|
||
[testenv] | ||
deps = pytest>=3.0 | ||
commands = pytest {posargs:tests} | ||
|
||
[testenv:flake8] | ||
skip_install = true | ||
deps = flake8 | ||
commands = flake8 pytest_subtests.py setup.py tests |