Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
810eb439
Commit
810eb439
authored
Dec 04, 2016
by
idle sign
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ConfigHandler.strict_mode.
parent
06715b63
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
4 deletions
+32
-4
setuptools/config.py
setuptools/config.py
+19
-2
setuptools/tests/test_config.py
setuptools/tests/test_config.py
+13
-2
No files found.
setuptools/config.py
View file @
810eb439
...
...
@@ -12,6 +12,16 @@ class ConfigHandler(object):
"""Handles metadata supplied in configuration files."""
section_prefix
=
None
"""Prefix for config sections handled by this handler.
Must be provided by class heirs.
"""
strict_mode
=
True
"""Flag. Whether unknown options in config should
raise DistutilsOptionError exception, or pass silently.
"""
def
__init__
(
self
,
target_obj
,
options
):
sections
=
{}
...
...
@@ -174,9 +184,11 @@ class ConfigHandler(object):
for
(
name
,
(
_
,
value
))
in
section_options
.
items
():
try
:
self
[
name
]
=
value
except
KeyError
:
raise
DistutilsOptionError
(
'Unknown distribution option: %s'
%
name
)
if
self
.
strict_mode
:
raise
DistutilsOptionError
(
'Unknown distribution option: %s'
%
name
)
def
parse
(
self
):
"""Parses configuration file items from one
...
...
@@ -203,6 +215,11 @@ class ConfigHandler(object):
class
ConfigMetadataHandler
(
ConfigHandler
):
section_prefix
=
'metadata'
strict_mode
=
False
"""We need to keep it loose, to be compatible with `pbr` package
which also uses `metadata` section.
"""
@
property
def
parsers
(
self
):
...
...
setuptools/tests/test_config.py
View file @
810eb439
...
...
@@ -130,8 +130,7 @@ class TestMetadata:
'unknown = some
\
n
'
)
with
get_dist
(
tmpdir
,
parse
=
False
)
as
dist
:
with
pytest
.
raises
(
DistutilsOptionError
):
dist
.
parse_config_files
()
dist
.
parse_config_files
()
# Skip unknown.
def
test_usupported_section
(
self
,
tmpdir
):
...
...
@@ -274,6 +273,18 @@ class TestOptions:
with
get_dist
(
tmpdir
)
as
dist
:
assert
dist
.
packages
==
[
'fake_package'
]
def
test_unknown_options_item
(
self
,
tmpdir
):
fake_env
(
tmpdir
,
'[options]
\
n
'
'zip_safe = True
\
n
'
'usr_2to3 = 1
\
n
'
)
with
get_dist
(
tmpdir
,
parse
=
False
)
as
dist
:
with
pytest
.
raises
(
DistutilsOptionError
):
dist
.
parse_config_files
()
def
test_extras_require
(
self
,
tmpdir
):
fake_env
(
tmpdir
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment