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
41eb0370
Commit
41eb0370
authored
Dec 25, 2015
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Plain Diff
Merged pull request #151 - prep work for issue #450.
parents
3172bf95
a9c37399
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
23 deletions
+74
-23
setuptools/tests/files.py
setuptools/tests/files.py
+32
-0
setuptools/tests/test_egg_info.py
setuptools/tests/test_egg_info.py
+42
-23
No files found.
setuptools/tests/files.py
0 → 100644
View file @
41eb0370
import
os
def
build_files
(
file_defs
,
prefix
=
""
):
"""
Build a set of files/directories, as described by the file_defs dictionary.
Each key/value pair in the dictionary is interpreted as a filename/contents
pair. If the contents value is a dictionary, a directory is created, and the
dictionary interpreted as the files within it, recursively.
For example:
{"README.txt": "A README file",
"foo": {
"__init__.py": "",
"bar": {
"__init__.py": "",
},
"baz.py": "# Some code",
}
}
"""
for
name
,
contents
in
file_defs
.
items
():
full_name
=
os
.
path
.
join
(
prefix
,
name
)
if
isinstance
(
contents
,
dict
):
if
not
os
.
path
.
exists
(
full_name
):
os
.
makedirs
(
full_name
)
build_files
(
contents
,
prefix
=
full_name
)
else
:
with
open
(
full_name
,
'w'
)
as
f
:
f
.
write
(
contents
)
setuptools/tests/test_egg_info.py
View file @
41eb0370
...
...
@@ -4,6 +4,7 @@ import stat
import
pytest
from
.
import
environment
from
.files
import
build_files
from
.textwrap
import
DALS
from
.
import
contexts
...
...
@@ -26,14 +27,13 @@ class TestEggInfo(object):
"""
)
def
_create_project
(
self
):
with
open
(
'setup.py'
,
'w'
)
as
f
:
f
.
write
(
self
.
setup_script
)
with
open
(
'hello.py'
,
'w'
)
as
f
:
f
.
write
(
DALS
(
"""
build_files
({
'setup.py'
:
self
.
setup_script
,
'hello.py'
:
DALS
(
"""
def run():
print('hello')
"""
))
"""
)
})
@
pytest
.
yield_fixture
def
env
(
self
):
...
...
@@ -46,17 +46,48 @@ class TestEggInfo(object):
for
dirname
in
subs
)
list
(
map
(
os
.
mkdir
,
env
.
paths
.
values
()))
config
=
os
.
path
.
join
(
env
.
paths
[
'home'
],
'.pydistutils.cfg'
)
with
open
(
config
,
'w'
)
as
f
:
f
.
write
(
DALS
(
"""
build_files
({
env
.
paths
[
'home'
]:
{
'.pydistutils.cfg'
:
DALS
(
"""
[egg_info]
egg-base = %(egg-base)s
"""
%
env
.
paths
))
"""
%
env
.
paths
)
}
})
yield
env
def
test_egg_base_installed_egg_info
(
self
,
tmpdir_cwd
,
env
):
self
.
_create_project
()
self
.
_run_install_command
(
tmpdir_cwd
,
env
)
_
,
actual
=
self
.
_find_egg_info_files
(
env
.
paths
[
'lib'
])
expected
=
[
'PKG-INFO'
,
'SOURCES.txt'
,
'dependency_links.txt'
,
'entry_points.txt'
,
'not-zip-safe'
,
'top_level.txt'
,
]
assert
sorted
(
actual
)
==
expected
def
test_manifest_template_is_read
(
self
,
tmpdir_cwd
,
env
):
self
.
_create_project
()
build_files
({
'MANIFEST.in'
:
DALS
(
"""
recursive-include docs *.rst
"""
),
'docs'
:
{
'usage.rst'
:
"Run 'hi'"
,
}
})
self
.
_run_install_command
(
tmpdir_cwd
,
env
)
egg_info_dir
,
_
=
self
.
_find_egg_info_files
(
env
.
paths
[
'lib'
])
sources_txt
=
os
.
path
.
join
(
egg_info_dir
,
'SOURCES.txt'
)
assert
'docs/usage.rst'
in
open
(
sources_txt
).
read
().
split
(
'
\
n
'
)
def
_run_install_command
(
self
,
tmpdir_cwd
,
env
):
environ
=
os
.
environ
.
copy
().
update
(
HOME
=
env
.
paths
[
'home'
],
)
...
...
@@ -76,21 +107,9 @@ class TestEggInfo(object):
if
code
:
raise
AssertionError
(
data
)
actual
=
self
.
_find_egg_info_files
(
env
.
paths
[
'lib'
])
expected
=
[
'PKG-INFO'
,
'SOURCES.txt'
,
'dependency_links.txt'
,
'entry_points.txt'
,
'not-zip-safe'
,
'top_level.txt'
,
]
assert
sorted
(
actual
)
==
expected
def
_find_egg_info_files
(
self
,
root
):
results
=
(
filenames
(
dirpath
,
filenames
)
for
dirpath
,
dirnames
,
filenames
in
os
.
walk
(
root
)
if
os
.
path
.
basename
(
dirpath
)
==
'EGG-INFO'
)
...
...
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