Merging upstream version 3.2.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
b0222c2f7f
commit
1f96436375
7 changed files with 27 additions and 45 deletions
33
.coveragerc
33
.coveragerc
|
@ -1,33 +0,0 @@
|
|||
[run]
|
||||
branch = True
|
||||
source =
|
||||
.
|
||||
omit =
|
||||
.tox/*
|
||||
/usr/*
|
||||
setup.py
|
||||
# Don't complain if non-runnable code isn't run
|
||||
*/__main__.py
|
||||
|
||||
[report]
|
||||
show_missing = True
|
||||
skip_covered = True
|
||||
exclude_lines =
|
||||
# Have to re-enable the standard pragma
|
||||
\#\s*pragma: no cover
|
||||
# We optionally substitute this
|
||||
${COVERAGE_IGNORE_WINDOWS}
|
||||
|
||||
# Don't complain if tests don't hit defensive assertion code:
|
||||
^\s*raise AssertionError\b
|
||||
^\s*raise NotImplementedError\b
|
||||
^\s*return NotImplemented\b
|
||||
^\s*raise$
|
||||
|
||||
# Don't complain if non-runnable code isn't run:
|
||||
^if __name__ == ['"]__main__['"]:$
|
||||
|
||||
[html]
|
||||
directory = coverage-html
|
||||
|
||||
# vim:ft=dosini
|
|
@ -10,29 +10,29 @@ repos:
|
|||
- id: name-tests-test
|
||||
- id: requirements-txt-fixer
|
||||
- repo: https://gitlab.com/pycqa/flake8
|
||||
rev: 3.7.9
|
||||
rev: 3.8.0
|
||||
hooks:
|
||||
- id: flake8
|
||||
- repo: https://github.com/pre-commit/mirrors-autopep8
|
||||
rev: v1.5
|
||||
rev: v1.5.2
|
||||
hooks:
|
||||
- id: autopep8
|
||||
- repo: https://github.com/asottile/reorder_python_imports
|
||||
rev: v1.9.0
|
||||
rev: v2.3.0
|
||||
hooks:
|
||||
- id: reorder-python-imports
|
||||
args: [--py3-plus]
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v1.26.2
|
||||
rev: v2.4.1
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: [--py36-plus]
|
||||
- repo: https://github.com/asottile/add-trailing-comma
|
||||
rev: v1.5.0
|
||||
rev: v2.0.1
|
||||
hooks:
|
||||
- id: add-trailing-comma
|
||||
args: [--py36-plus]
|
||||
- repo: https://github.com/asottile/setup-cfg-fmt
|
||||
rev: v1.6.0
|
||||
rev: v1.9.0
|
||||
hooks:
|
||||
- id: setup-cfg-fmt
|
||||
|
|
5
cfgv.py
5
cfgv.py
|
@ -395,10 +395,13 @@ def load_from_filename(
|
|||
if not os.path.exists(filename):
|
||||
raise ValidationError(f'{filename} does not exist')
|
||||
|
||||
with validate_context(f'File {filename}'):
|
||||
try:
|
||||
with open(filename, encoding='utf-8') as f:
|
||||
contents = f.read()
|
||||
except UnicodeDecodeError as e:
|
||||
raise ValidationError(str(e))
|
||||
|
||||
with validate_context(f'File {filename}'):
|
||||
try:
|
||||
data = load_strategy(contents)
|
||||
except Exception as e:
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
covdefaults
|
||||
coverage
|
||||
pre-commit
|
||||
pytest
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[metadata]
|
||||
name = cfgv
|
||||
version = 3.1.0
|
||||
version = 3.2.0
|
||||
description = Validate configuration and produce human readable error messages.
|
||||
long_description = file: README.md
|
||||
long_description_content_type = text/markdown
|
||||
|
@ -25,3 +25,6 @@ python_requires = >=3.6.1
|
|||
|
||||
[bdist_wheel]
|
||||
universal = True
|
||||
|
||||
[coverage:run]
|
||||
plugins = covdefaults
|
||||
|
|
|
@ -532,6 +532,16 @@ def test_load_from_filename_file_does_not_exist():
|
|||
assert excinfo.value.args[0].error_msg == 'does_not_exist does not exist'
|
||||
|
||||
|
||||
def test_load_from_filename_unicode_error(tmp_path):
|
||||
f = tmp_path.joinpath('f')
|
||||
f.write_bytes(b'\x98\xae\xfe')
|
||||
|
||||
with pytest.raises(Error) as excinfo:
|
||||
load_from_filename(f, map_required, json.loads, Error)
|
||||
expected = (f'File {f}', mock.ANY)
|
||||
_assert_exception_trace(excinfo.value.args[0], expected)
|
||||
|
||||
|
||||
def test_load_from_filename_fails_load_strategy(tmpdir):
|
||||
f = tmpdir.join('foo.notjson')
|
||||
f.write('totes not json')
|
||||
|
|
1
tox.ini
1
tox.ini
|
@ -7,7 +7,6 @@ commands =
|
|||
coverage erase
|
||||
coverage run -m pytest {posargs:tests}
|
||||
coverage report --fail-under 100
|
||||
pre-commit install
|
||||
|
||||
[testenv:pre-commit]
|
||||
skip_install = true
|
||||
|
|
Loading…
Add table
Reference in a new issue