forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for multiversion testing with tox (python#21)
Also full coverage for all supported Pythons.
- Loading branch information
Showing
10 changed files
with
144 additions
and
34 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 |
---|---|---|
|
@@ -99,3 +99,4 @@ ENV/ | |
|
||
# mypy | ||
.mypy_cache/ | ||
/diffcov.html |
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,26 @@ | ||
[run] | ||
branch = true | ||
parallel = true | ||
omit = | ||
setup* | ||
.tox/*/lib/python3.*/site-packages/* | ||
.tox/*/lib/python3.*/site-packages/* | ||
*/tests/*.py | ||
/tmp/* | ||
/private/var/folders/* | ||
*/testing/*.py | ||
|
||
[report] | ||
exclude_lines = | ||
pragma: nocover | ||
pragma: missed | ||
pragma: ge${GEVER} | ||
pragma: le${LEVER} | ||
raise NotImplementedError | ||
raise AssertionError | ||
assert\s | ||
|
||
[paths] | ||
source = | ||
importlib_resources | ||
.tox/*/lib/python*/site-packages/importlib_resources |
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
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 |
---|---|---|
@@ -1,25 +1,32 @@ | ||
import abc | ||
|
||
from typing.io import BinaryIO | ||
|
||
|
||
class ResourceReader(abc.ABC): | ||
|
||
"""Abstract base class for loaders to provide resource reading support.""" | ||
|
||
@abc.abstractmethod | ||
def open_resource(self, path: str) -> BinaryIO: | ||
"""Return an opened, file-like object for binary reading of the resource. | ||
"""Return an opened, file-like object for binary reading. | ||
The 'path' argument is expected to represent only a file name. | ||
If the resource cannot be found, FileNotFoundError is raised. | ||
""" | ||
raise FileNotFoundError | ||
# This deliberately raises FileNotFoundError instead of | ||
# NotImplementedError so that if this method is accidentally called, | ||
# it'll still do the right thing. | ||
raise FileNotFoundError # pragma: nocover | ||
|
||
@abc.abstractmethod | ||
def resource_path(self, path: str) -> str: | ||
"""Return the file system path to the specified resource. | ||
The 'path' argument is expected to represent only a file name. | ||
If the resource does not exist on the file system, raise | ||
FileNotFoundError. | ||
""" | ||
raise FileNotFoundError | ||
# This deliberately raises FileNotFoundError instead of | ||
# NotImplementedError so that if this method is accidentally called, | ||
# it'll still do the right thing. | ||
raise FileNotFoundError # pragma: nocover |
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
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
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
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
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,14 @@ | ||
import sys | ||
|
||
from setuptools import setup | ||
|
||
|
||
requirements = [] | ||
if sys.version_info < (3,): | ||
requirements.append('pathlib2') | ||
|
||
|
||
setup( | ||
name='importlib_resources', | ||
install_requires=requirements, | ||
) |
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,61 @@ | ||
[tox] | ||
envlist = {py34,py35,py36,py37}-{nocov,cov,diffcov},qa | ||
skip_missing_interpreters = True | ||
|
||
|
||
[testenv] | ||
commands = | ||
nocov: python -m unittest discover | ||
cov,diffcov: python -m coverage run {[coverage]rc} -m unittest discover {posargs} | ||
cov,diffcov: python -m coverage combine {[coverage]rc} | ||
cov: python -m coverage html {[coverage]rc} | ||
cov: python -m coverage report -m {[coverage]rc} --fail-under=100 | ||
diffcov: python -m coverage xml {[coverage]rc} | ||
diffcov: diff-cover coverage.xml --html-report diffcov.html | ||
diffcov: diff-cover coverage.xml --fail-under=100 | ||
usedevelop = True | ||
passenv = | ||
PYTHON* | ||
LANG* | ||
LC_* | ||
deps = | ||
cov,diffcov: coverage | ||
diffcov: diff_cover | ||
setenv = | ||
cov: COVERAGE_PROCESS_START={[coverage]rcfile} | ||
cov: COVERAGE_OPTIONS="-p" | ||
cov: COVERAGE_FILE={toxinidir}/.coverage | ||
py34: GEVER=35 | ||
py35: GEVER=36 | ||
py36: GEVER=37 | ||
py36: LEVER=35 | ||
|
||
|
||
[testenv:qa] | ||
basepython = python3 | ||
commands = | ||
python -m flake8 importlib_resources | ||
py34,py35,py36: mypy --ignore-missing-imports importlib_resources | ||
deps = | ||
py34,py35,py36: mypy | ||
flake8 | ||
|
||
|
||
[testenv:docs] | ||
basepython = python3 | ||
commands = | ||
python setup.py build_sphinx | ||
deps: | ||
sphinx | ||
docutils==0.12 | ||
|
||
|
||
[coverage] | ||
rcfile = {toxinidir}/coverage.ini | ||
rc = --rcfile={[coverage]rcfile} | ||
|
||
|
||
[flake8] | ||
hang-closing = True | ||
jobs = 1 | ||
max-line-length = 79 |