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
b73891f8
Commit
b73891f8
authored
Dec 10, 2016
by
idle sign
Committed by
Jason R. Coombs
Dec 10, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config tests refactored.
parent
56dea7f0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
17 deletions
+26
-17
setuptools/tests/test_config.py
setuptools/tests/test_config.py
+26
-17
No files found.
setuptools/tests/test_config.py
View file @
b73891f8
...
@@ -9,6 +9,13 @@ class ErrConfigHandler(ConfigHandler):
...
@@ -9,6 +9,13 @@ class ErrConfigHandler(ConfigHandler):
"""Erroneous handler. Fails to implement required methods."""
"""Erroneous handler. Fails to implement required methods."""
def
make_package_dir
(
name
,
base_dir
):
dir_package
=
base_dir
.
mkdir
(
name
)
init_file
=
dir_package
.
join
(
'__init__.py'
)
init_file
.
write
(
''
)
return
dir_package
,
init_file
def
fake_env
(
tmpdir
,
setup_cfg
,
setup_py
=
None
):
def
fake_env
(
tmpdir
,
setup_cfg
,
setup_py
=
None
):
if
setup_py
is
None
:
if
setup_py
is
None
:
...
@@ -18,11 +25,12 @@ def fake_env(tmpdir, setup_cfg, setup_py=None):
...
@@ -18,11 +25,12 @@ def fake_env(tmpdir, setup_cfg, setup_py=None):
)
)
tmpdir
.
join
(
'setup.py'
).
write
(
setup_py
)
tmpdir
.
join
(
'setup.py'
).
write
(
setup_py
)
tmpdir
.
join
(
'setup.cfg'
).
write
(
setup_cfg
)
config
=
tmpdir
.
join
(
'setup.cfg'
)
config
.
write
(
setup_cfg
)
package_dir
,
init_file
=
make_package_dir
(
'fake_package'
,
tmpdir
)
package_name
=
'fake_package'
init_file
.
write
(
dir_package
=
tmpdir
.
mkdir
(
package_name
)
dir_package
.
join
(
'__init__.py'
).
write
(
'VERSION = (1, 2, 3)
\
n
'
'VERSION = (1, 2, 3)
\
n
'
'
\
n
'
'
\
n
'
'VERSION_MAJOR = 1'
'VERSION_MAJOR = 1'
...
@@ -31,6 +39,7 @@ def fake_env(tmpdir, setup_cfg, setup_py=None):
...
@@ -31,6 +39,7 @@ def fake_env(tmpdir, setup_cfg, setup_py=None):
' return [3, 4, 5, "dev"]
\
n
'
' return [3, 4, 5, "dev"]
\
n
'
'
\
n
'
'
\
n
'
)
)
return
package_dir
,
config
@
contextlib
.
contextmanager
@
contextlib
.
contextmanager
...
@@ -55,7 +64,7 @@ def test_parsers_implemented():
...
@@ -55,7 +64,7 @@ def test_parsers_implemented():
class
TestConfigurationReader
:
class
TestConfigurationReader
:
def
test_basic
(
self
,
tmpdir
):
def
test_basic
(
self
,
tmpdir
):
fake_env
(
_
,
config
=
fake_env
(
tmpdir
,
tmpdir
,
'[metadata]
\
n
'
'[metadata]
\
n
'
'version = 10.1.1
\
n
'
'version = 10.1.1
\
n
'
...
@@ -64,7 +73,7 @@ class TestConfigurationReader:
...
@@ -64,7 +73,7 @@ class TestConfigurationReader:
'[options]
\
n
'
'[options]
\
n
'
'scripts = bin/a.py, bin/b.py
\
n
'
'scripts = bin/a.py, bin/b.py
\
n
'
)
)
config_dict
=
read_configuration
(
'%s'
%
tmpdir
.
join
(
'setup.cfg'
)
)
config_dict
=
read_configuration
(
'%s'
%
config
)
assert
config_dict
[
'metadata'
][
'version'
]
==
'10.1.1'
assert
config_dict
[
'metadata'
][
'version'
]
==
'10.1.1'
assert
config_dict
[
'metadata'
][
'keywords'
]
==
[
'one'
,
'two'
]
assert
config_dict
[
'metadata'
][
'keywords'
]
==
[
'one'
,
'two'
]
assert
config_dict
[
'options'
][
'scripts'
]
==
[
'bin/a.py'
,
'bin/b.py'
]
assert
config_dict
[
'options'
][
'scripts'
]
==
[
'bin/a.py'
,
'bin/b.py'
]
...
@@ -74,17 +83,17 @@ class TestConfigurationReader:
...
@@ -74,17 +83,17 @@ class TestConfigurationReader:
read_configuration
(
'%s'
%
tmpdir
.
join
(
'setup.cfg'
))
read_configuration
(
'%s'
%
tmpdir
.
join
(
'setup.cfg'
))
def
test_ignore_errors
(
self
,
tmpdir
):
def
test_ignore_errors
(
self
,
tmpdir
):
fake_env
(
_
,
config
=
fake_env
(
tmpdir
,
tmpdir
,
'[metadata]
\
n
'
'[metadata]
\
n
'
'version = attr: none.VERSION
\
n
'
'version = attr: none.VERSION
\
n
'
'keywords = one, two
\
n
'
'keywords = one, two
\
n
'
)
)
with
pytest
.
raises
(
ImportError
):
with
pytest
.
raises
(
ImportError
):
read_configuration
(
'%s'
%
tmpdir
.
join
(
'setup.cfg'
)
)
read_configuration
(
'%s'
%
config
)
config_dict
=
read_configuration
(
config_dict
=
read_configuration
(
'%s'
%
tmpdir
.
join
(
'setup.cfg'
)
,
ignore_option_errors
=
True
)
'%s'
%
config
,
ignore_option_errors
=
True
)
assert
config_dict
[
'metadata'
][
'keywords'
]
==
[
'one'
,
'two'
]
assert
config_dict
[
'metadata'
][
'keywords'
]
==
[
'one'
,
'two'
]
assert
'version'
not
in
config_dict
[
'metadata'
]
assert
'version'
not
in
config_dict
[
'metadata'
]
...
@@ -188,7 +197,7 @@ class TestMetadata:
...
@@ -188,7 +197,7 @@ class TestMetadata:
def
test_version
(
self
,
tmpdir
):
def
test_version
(
self
,
tmpdir
):
fake_env
(
_
,
config
=
fake_env
(
tmpdir
,
tmpdir
,
'[metadata]
\
n
'
'[metadata]
\
n
'
'version = attr: fake_package.VERSION
\
n
'
'version = attr: fake_package.VERSION
\
n
'
...
@@ -196,14 +205,14 @@ class TestMetadata:
...
@@ -196,14 +205,14 @@ class TestMetadata:
with
get_dist
(
tmpdir
)
as
dist
:
with
get_dist
(
tmpdir
)
as
dist
:
assert
dist
.
metadata
.
version
==
'1.2.3'
assert
dist
.
metadata
.
version
==
'1.2.3'
tmpdir
.
join
(
'setup.cfg'
)
.
write
(
config
.
write
(
'[metadata]
\
n
'
'[metadata]
\
n
'
'version = attr: fake_package.get_version
\
n
'
'version = attr: fake_package.get_version
\
n
'
)
)
with
get_dist
(
tmpdir
)
as
dist
:
with
get_dist
(
tmpdir
)
as
dist
:
assert
dist
.
metadata
.
version
==
'3.4.5.dev'
assert
dist
.
metadata
.
version
==
'3.4.5.dev'
tmpdir
.
join
(
'setup.cfg'
)
.
write
(
config
.
write
(
'[metadata]
\
n
'
'[metadata]
\
n
'
'version = attr: fake_package.VERSION_MAJOR
\
n
'
'version = attr: fake_package.VERSION_MAJOR
\
n
'
)
)
...
@@ -214,7 +223,7 @@ class TestMetadata:
...
@@ -214,7 +223,7 @@ class TestMetadata:
subpack
.
join
(
'__init__.py'
).
write
(
''
)
subpack
.
join
(
'__init__.py'
).
write
(
''
)
subpack
.
join
(
'submodule.py'
).
write
(
'VERSION = (2016, 11, 26)'
)
subpack
.
join
(
'submodule.py'
).
write
(
'VERSION = (2016, 11, 26)'
)
tmpdir
.
join
(
'setup.cfg'
)
.
write
(
config
.
write
(
'[metadata]
\
n
'
'[metadata]
\
n
'
'version = attr: fake_package.subpackage.submodule.VERSION
\
n
'
'version = attr: fake_package.subpackage.submodule.VERSION
\
n
'
)
)
...
@@ -250,7 +259,7 @@ class TestMetadata:
...
@@ -250,7 +259,7 @@ class TestMetadata:
])
])
# From file.
# From file.
fake_env
(
_
,
config
=
fake_env
(
tmpdir
,
tmpdir
,
'[metadata]
\
n
'
'[metadata]
\
n
'
'classifiers = file: classifiers
\
n
'
'classifiers = file: classifiers
\
n
'
...
@@ -265,7 +274,7 @@ class TestMetadata:
...
@@ -265,7 +274,7 @@ class TestMetadata:
assert
set
(
dist
.
metadata
.
classifiers
)
==
expected
assert
set
(
dist
.
metadata
.
classifiers
)
==
expected
# From section.
# From section.
tmpdir
.
join
(
'setup.cfg'
)
.
write
(
config
.
write
(
'[metadata.classifiers]
\
n
'
'[metadata.classifiers]
\
n
'
'Framework :: Django
\
n
'
'Framework :: Django
\
n
'
'Programming Language :: Python :: 3.5
\
n
'
'Programming Language :: Python :: 3.5
\
n
'
...
@@ -454,7 +463,7 @@ class TestOptions:
...
@@ -454,7 +463,7 @@ class TestOptions:
}
}
def
test_entry_points
(
self
,
tmpdir
):
def
test_entry_points
(
self
,
tmpdir
):
fake_env
(
_
,
config
=
fake_env
(
tmpdir
,
tmpdir
,
'[options.entry_points]
\
n
'
'[options.entry_points]
\
n
'
'group1 = point1 = pack.module:func, '
'group1 = point1 = pack.module:func, '
...
@@ -479,7 +488,7 @@ class TestOptions:
...
@@ -479,7 +488,7 @@ class TestOptions:
tmpdir
.
join
(
'entry_points'
).
write
(
expected
)
tmpdir
.
join
(
'entry_points'
).
write
(
expected
)
# From file.
# From file.
tmpdir
.
join
(
'setup.cfg'
)
.
write
(
config
.
write
(
'[options]
\
n
'
'[options]
\
n
'
'entry_points = file: entry_points
\
n
'
'entry_points = file: entry_points
\
n
'
)
)
...
...
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