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
27d755c7
Commit
27d755c7
authored
Aug 09, 2013
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove import *
parent
a2d99b96
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
22 deletions
+26
-22
setuptools.egg-info/requires.txt
setuptools.egg-info/requires.txt
+4
-4
setuptools/tests/test_resources.py
setuptools/tests/test_resources.py
+22
-18
No files found.
setuptools.egg-info/requires.txt
View file @
27d755c7
[ssl:sys_platform=='win32' and python_version=='2.4']
ctypes==1.0.2
[ssl:sys_platform=='win32']
wincertstore==0.1
...
...
@@ -11,3 +8,6 @@ certifi==0.0.8
[ssl:python_version in '2.4, 2.5']
ssl==1.16
[ssl:sys_platform=='win32' and python_version=='2.4']
ctypes==1.0.2
\ No newline at end of file
setuptools/tests/test_resources.py
View file @
27d755c7
...
...
@@ -9,7 +9,9 @@ import shutil
from
unittest
import
TestCase
import
pkg_resources
from
pkg_resources
import
*
from
pkg_resources
import
(
parse_requirements
,
VersionConflict
,
parse_version
,
Distribution
,
EntryPoint
,
Requirement
,
safe_version
,
safe_name
,
WorkingSet
)
from
setuptools.command.easy_install
import
get_script_header
,
is_sh
from
setuptools.compat
import
StringIO
,
iteritems
...
...
@@ -25,11 +27,11 @@ def safe_repr(obj, short=False):
result
=
repr
(
obj
)
except
Exception
:
result
=
object
.
__repr__
(
obj
)
if
not
short
or
len
(
result
)
<
_MAX_LENGTH
:
if
not
short
or
len
(
result
)
<
pkg_resources
.
_MAX_LENGTH
:
return
result
return
result
[:
_MAX_LENGTH
]
+
' [truncated]...'
return
result
[:
pkg_resources
.
_MAX_LENGTH
]
+
' [truncated]...'
class
Metadata
(
EmptyProvider
):
class
Metadata
(
pkg_resources
.
EmptyProvider
):
"""Mock object to return metadata as if from an on-disk distribution"""
def
__init__
(
self
,
*
pairs
):
...
...
@@ -42,18 +44,20 @@ class Metadata(EmptyProvider):
return
self
.
metadata
[
name
]
def
get_metadata_lines
(
self
,
name
):
return
yield_lines
(
self
.
get_metadata
(
name
))
return
pkg_resources
.
yield_lines
(
self
.
get_metadata
(
name
))
dist_from_fn
=
pkg_resources
.
Distribution
.
from_filename
class
DistroTests
(
TestCase
):
def
testCollection
(
self
):
# empty path should produce no distributions
ad
=
Environment
([],
platform
=
None
,
python
=
None
)
ad
=
pkg_resources
.
Environment
([],
platform
=
None
,
python
=
None
)
self
.
assertEqual
(
list
(
ad
),
[])
self
.
assertEqual
(
ad
[
'FooPkg'
],[])
ad
.
add
(
Distribution
.
from_filename
(
"FooPkg-1.3_1.egg"
))
ad
.
add
(
Distribution
.
from_filename
(
"FooPkg-1.4-py2.4-win32.egg"
))
ad
.
add
(
Distribution
.
from_filename
(
"FooPkg-1.2-py2.4.egg"
))
ad
.
add
(
dist_from_fn
(
"FooPkg-1.3_1.egg"
))
ad
.
add
(
dist_from_fn
(
"FooPkg-1.4-py2.4-win32.egg"
))
ad
.
add
(
dist_from_fn
(
"FooPkg-1.2-py2.4.egg"
))
# Name is in there now
self
.
assertTrue
(
ad
[
'FooPkg'
])
...
...
@@ -70,14 +74,14 @@ class DistroTests(TestCase):
[
dist
.
version
for
dist
in
ad
[
'FooPkg'
]],
[
'1.4'
,
'1.2'
]
)
# And inserting adds them in order
ad
.
add
(
Distribution
.
from_filename
(
"FooPkg-1.9.egg"
))
ad
.
add
(
dist_from_fn
(
"FooPkg-1.9.egg"
))
self
.
assertEqual
(
[
dist
.
version
for
dist
in
ad
[
'FooPkg'
]],
[
'1.9'
,
'1.4'
,
'1.2'
]
)
ws
=
WorkingSet
([])
foo12
=
Distribution
.
from_filename
(
"FooPkg-1.2-py2.4.egg"
)
foo14
=
Distribution
.
from_filename
(
"FooPkg-1.4-py2.4-win32.egg"
)
foo12
=
dist_from_fn
(
"FooPkg-1.2-py2.4.egg"
)
foo14
=
dist_from_fn
(
"FooPkg-1.4-py2.4-win32.egg"
)
req
,
=
parse_requirements
(
"FooPkg>=1.3"
)
# Nominal case: no distros on path, should yield all applicable
...
...
@@ -119,9 +123,9 @@ class DistroTests(TestCase):
self
.
assertEqual
(
d
.
platform
,
None
)
def
testDistroParse
(
self
):
d
=
Distribution
.
from_filename
(
"FooPkg-1.3_1-py2.4-win32.egg"
)
d
=
dist_from_fn
(
"FooPkg-1.3_1-py2.4-win32.egg"
)
self
.
checkFooPkg
(
d
)
d
=
Distribution
.
from_filename
(
"FooPkg-1.3_1-py2.4-win32.egg-info"
)
d
=
dist_from_fn
(
"FooPkg-1.3_1-py2.4-win32.egg-info"
)
self
.
checkFooPkg
(
d
)
def
testDistroMetadata
(
self
):
...
...
@@ -147,13 +151,13 @@ class DistroTests(TestCase):
self
.
checkRequires
(
self
.
distRequires
(
v
),
v
)
def
testResolve
(
self
):
ad
=
Environment
([])
ad
=
pkg_resources
.
Environment
([])
ws
=
WorkingSet
([])
# Resolving no requirements -> nothing to install
self
.
assertEqual
(
list
(
ws
.
resolve
([],
ad
)),
[])
# Request something not in the collection -> DistributionNotFound
self
.
assertRaises
(
DistributionNotFound
,
ws
.
resolve
,
parse_requirements
(
"Foo"
),
ad
pkg_resources
.
DistributionNotFound
,
ws
.
resolve
,
parse_requirements
(
"Foo"
),
ad
)
Foo
=
Distribution
.
from_filename
(
"/foo_dir/Foo-1.2.egg"
,
...
...
@@ -173,7 +177,7 @@ class DistroTests(TestCase):
# Request an extra that causes an unresolved dependency for "Baz"
self
.
assertRaises
(
DistributionNotFound
,
ws
.
resolve
,
parse_requirements
(
"Foo[bar]"
),
ad
pkg_resources
.
DistributionNotFound
,
ws
.
resolve
,
parse_requirements
(
"Foo[bar]"
),
ad
)
Baz
=
Distribution
.
from_filename
(
"/foo_dir/Baz-2.1.egg"
,
metadata
=
Metadata
((
'depends.txt'
,
"Foo"
))
...
...
@@ -211,7 +215,7 @@ class DistroTests(TestCase):
d
,
"Twisted>=1.5 fcgiapp>=0.1 ZConfig>=2.0 docutils>=0.3"
.
split
(),
[
"fastcgi"
,
"docgen"
]
)
self
.
assertRaises
(
UnknownExtra
,
d
.
requires
,
[
"foo"
])
self
.
assertRaises
(
pkg_resources
.
UnknownExtra
,
d
.
requires
,
[
"foo"
])
class
EntryPointTests
(
TestCase
):
...
...
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