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
141d093b
Commit
141d093b
authored
Nov 28, 2015
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move test into pkg_resources tests
parent
03e7e8c2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
96 additions
and
85 deletions
+96
-85
pkg_resources/tests/test_pkg_resources.py
pkg_resources/tests/test_pkg_resources.py
+96
-0
setuptools/tests/test_egg_info.py
setuptools/tests/test_egg_info.py
+0
-85
No files found.
pkg_resources/tests/test_pkg_resources.py
View file @
141d093b
...
...
@@ -5,9 +5,17 @@ import zipfile
import
datetime
import
time
import
subprocess
import
stat
import
pytest
import
pkg_resources
from
setuptools.tests.textwrap
import
DALS
from
setuptools.tests
import
contexts
from
setuptools.tests
import
environment
try
:
unicode
except
NameError
:
...
...
@@ -109,3 +117,91 @@ class TestIndependence:
)
cmd
=
[
sys
.
executable
,
'-c'
,
'; '
.
join
(
lines
)]
subprocess
.
check_call
(
cmd
)
class
TestEggInfoDistutils
(
object
):
version
=
'1.11.0.dev0+2329eae'
setup_script
=
DALS
(
"""
from distutils.core import setup
setup(
name='foo',
py_modules=['hello'],
version='%s',
)
"""
)
def
_create_project
(
self
):
with
open
(
'setup.py'
,
'w'
)
as
f
:
f
.
write
(
self
.
setup_script
%
self
.
version
)
with
open
(
'hello.py'
,
'w'
)
as
f
:
f
.
write
(
DALS
(
"""
def run():
print('hello')
"""
))
@
pytest
.
yield_fixture
def
env
(
self
):
class
Environment
(
str
):
pass
with
contexts
.
tempdir
(
prefix
=
'setuptools-test.'
)
as
env_dir
:
env
=
Environment
(
env_dir
)
os
.
chmod
(
env_dir
,
stat
.
S_IRWXU
)
subs
=
'home'
,
'lib'
,
'scripts'
,
'data'
,
'egg-base'
env
.
paths
=
dict
(
(
dirname
,
os
.
path
.
join
(
env_dir
,
dirname
))
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
(
"""
[egg_info]
egg-base = %(egg-base)s
"""
%
env
.
paths
))
yield
env
def
test_egg_base_installed_egg_info
(
self
,
tmpdir_cwd
,
env
):
self
.
_create_project
()
environ
=
os
.
environ
.
copy
().
update
(
HOME
=
env
.
paths
[
'home'
],
)
cmd
=
[
'install'
,
'--home'
,
env
.
paths
[
'home'
],
'--install-lib'
,
env
.
paths
[
'lib'
],
'--install-scripts'
,
env
.
paths
[
'scripts'
],
'--install-data'
,
env
.
paths
[
'data'
],
]
code
,
data
=
environment
.
run_setup_py
(
cmd
=
cmd
,
pypath
=
os
.
pathsep
.
join
([
env
.
paths
[
'lib'
],
str
(
tmpdir_cwd
)]),
data_stream
=
1
,
env
=
environ
,
)
if
code
:
raise
AssertionError
(
data
)
actual
=
self
.
_find_egg_info_file
(
env
.
paths
[
'lib'
])
# On Py3k it can be e.g. foo-1.11.0.dev0_2329eae-py3.4.egg-info
# but 2.7 doesn't add the Python version, so to be expedient we
# just check our start and end, omitting the potential version num
assert
actual
.
startswith
(
'foo-'
+
self
.
version
.
replace
(
'+'
,
'_'
))
assert
actual
.
endswith
(
'.egg-info'
)
# this requirement parsing will raise a VersionConflict unless the
# .egg-info file is parsed (see #419 on BitBucket)
req
=
pkg_resources
.
Requirement
.
parse
(
'foo>=1.9'
)
dist
=
pkg_resources
.
WorkingSet
([
env
.
paths
[
'lib'
]]).
find
(
req
)
assert
dist
.
version
==
self
.
version
def
_find_egg_info_file
(
self
,
root
):
# expect exactly one result
result
=
(
filename
for
dirpath
,
dirnames
,
filenames
in
os
.
walk
(
root
)
for
filename
in
filenames
if
filename
.
endswith
(
'.egg-info'
))
result
,
=
result
return
result
setuptools/tests/test_egg_info.py
View file @
141d093b
...
...
@@ -6,7 +6,6 @@ import pytest
from
.
import
environment
from
.textwrap
import
DALS
from
.
import
contexts
from
pkg_resources
import
WorkingSet
,
Requirement
class
Environment
(
str
):
...
...
@@ -98,87 +97,3 @@ class TestEggInfo(object):
# expect exactly one result
result
,
=
results
return
result
class
TestEggInfoDistutils
(
object
):
version
=
'1.11.0.dev0+2329eae'
setup_script
=
DALS
(
"""
from distutils.core import setup
setup(
name='foo',
py_modules=['hello'],
version='%s',
)
"""
)
def
_create_project
(
self
):
with
open
(
'setup.py'
,
'w'
)
as
f
:
f
.
write
(
self
.
setup_script
%
self
.
version
)
with
open
(
'hello.py'
,
'w'
)
as
f
:
f
.
write
(
DALS
(
"""
def run():
print('hello')
"""
))
@
pytest
.
yield_fixture
def
env
(
self
):
with
contexts
.
tempdir
(
prefix
=
'setuptools-test.'
)
as
env_dir
:
env
=
Environment
(
env_dir
)
os
.
chmod
(
env_dir
,
stat
.
S_IRWXU
)
subs
=
'home'
,
'lib'
,
'scripts'
,
'data'
,
'egg-base'
env
.
paths
=
dict
(
(
dirname
,
os
.
path
.
join
(
env_dir
,
dirname
))
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
(
"""
[egg_info]
egg-base = %(egg-base)s
"""
%
env
.
paths
))
yield
env
def
test_egg_base_installed_egg_info
(
self
,
tmpdir_cwd
,
env
):
self
.
_create_project
()
environ
=
os
.
environ
.
copy
().
update
(
HOME
=
env
.
paths
[
'home'
],
)
cmd
=
[
'install'
,
'--home'
,
env
.
paths
[
'home'
],
'--install-lib'
,
env
.
paths
[
'lib'
],
'--install-scripts'
,
env
.
paths
[
'scripts'
],
'--install-data'
,
env
.
paths
[
'data'
],
]
code
,
data
=
environment
.
run_setup_py
(
cmd
=
cmd
,
pypath
=
os
.
pathsep
.
join
([
env
.
paths
[
'lib'
],
str
(
tmpdir_cwd
)]),
data_stream
=
1
,
env
=
environ
,
)
if
code
:
raise
AssertionError
(
data
)
actual
=
self
.
_find_egg_info_file
(
env
.
paths
[
'lib'
])
# On Py3k it can be e.g. foo-1.11.0.dev0_2329eae-py3.4.egg-info
# but 2.7 doesn't add the Python version, so to be expedient we
# just check our start and end, omitting the potential version num
assert
actual
.
startswith
(
'foo-'
+
self
.
version
.
replace
(
'+'
,
'_'
))
assert
actual
.
endswith
(
'.egg-info'
)
# this requirement parsing will raise a VersionConflict unless the
# .egg-info file is parsed (see #419 on BitBucket)
req
=
Requirement
.
parse
(
'foo>=1.9'
)
dist
=
WorkingSet
([
env
.
paths
[
'lib'
]]).
find
(
req
)
assert
dist
.
version
==
self
.
version
def
_find_egg_info_file
(
self
,
root
):
# expect exactly one result
result
=
(
filename
for
dirpath
,
dirnames
,
filenames
in
os
.
walk
(
root
)
for
filename
in
filenames
if
filename
.
endswith
(
'.egg-info'
))
result
,
=
result
return
result
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