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
a9350f32
Commit
a9350f32
authored
Dec 07, 2016
by
idle sign
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
`read_configuration` now chdirs and tests for file.
parent
43af23dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
setuptools/config.py
setuptools/config.py
+12
-1
setuptools/tests/test_config.py
setuptools/tests/test_config.py
+5
-1
No files found.
setuptools/config.py
View file @
a9350f32
...
...
@@ -5,7 +5,7 @@ import sys
from
collections
import
defaultdict
from
functools
import
partial
from
distutils.errors
import
DistutilsOptionError
from
distutils.errors
import
DistutilsOptionError
,
DistutilsFileError
from
setuptools.py26compat
import
import_module
from
setuptools.extern.six
import
string_types
...
...
@@ -23,6 +23,15 @@ def read_configuration(filepath, find_others=False):
"""
from
setuptools.dist
import
Distribution
,
_Distribution
filepath
=
os
.
path
.
abspath
(
filepath
)
if
not
os
.
path
.
isfile
(
filepath
):
raise
DistutilsFileError
(
'Configuration file %s does not exist.'
%
filepath
)
current_directory
=
os
.
getcwd
()
os
.
chdir
(
os
.
path
.
dirname
(
filepath
))
dist
=
Distribution
()
filenames
=
dist
.
find_config_files
()
if
find_others
else
[]
...
...
@@ -33,6 +42,8 @@ def read_configuration(filepath, find_others=False):
handlers
=
parse_configuration
(
dist
,
dist
.
command_options
)
os
.
chdir
(
current_directory
)
return
configuration_to_dict
(
handlers
)
...
...
setuptools/tests/test_config.py
View file @
a9350f32
import
contextlib
import
pytest
from
distutils.errors
import
DistutilsOptionError
from
distutils.errors
import
DistutilsOptionError
,
DistutilsFileError
from
setuptools.dist
import
Distribution
from
setuptools.config
import
ConfigHandler
,
read_configuration
...
...
@@ -69,6 +69,10 @@ class TestConfigurationReader:
assert
config_dict
[
'metadata'
][
'keywords'
]
==
[
'one'
,
'two'
]
assert
config_dict
[
'options'
][
'scripts'
]
==
[
'bin/a.py'
,
'bin/b.py'
]
def
test_no_config
(
self
,
tmpdir
):
with
pytest
.
raises
(
DistutilsFileError
):
read_configuration
(
'%s'
%
tmpdir
.
join
(
'setup.cfg'
))
class
TestMetadata
:
...
...
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