Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f879e32c
Commit
f879e32c
authored
May 25, 2012
by
Eric V. Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added test for namespace package dynamic path updates.
parent
739ae569
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
+45
-0
Lib/test/test_namespace_pkgs.py
Lib/test/test_namespace_pkgs.py
+45
-0
No files found.
Lib/test/test_namespace_pkgs.py
View file @
f879e32c
...
...
@@ -206,6 +206,51 @@ class LegacySupport(NamespacePackageTest):
self
.
assertNotIn
(
'namespace'
,
str
(
foo
.
__loader__
).
lower
())
class
DynamicPathCalculation
(
NamespacePackageTest
):
paths
=
[
'project1'
,
'project2'
]
def
test_project3_fails
(
self
):
import
parent.child.one
self
.
assertEqual
(
len
(
parent
.
__path__
),
2
)
self
.
assertEqual
(
len
(
parent
.
child
.
__path__
),
2
)
import
parent.child.two
self
.
assertEqual
(
len
(
parent
.
__path__
),
2
)
self
.
assertEqual
(
len
(
parent
.
child
.
__path__
),
2
)
self
.
assertEqual
(
parent
.
child
.
one
.
attr
,
'parent child one'
)
self
.
assertEqual
(
parent
.
child
.
two
.
attr
,
'parent child two'
)
with
self
.
assertRaises
(
ImportError
):
import
parent.child.three
self
.
assertEqual
(
len
(
parent
.
__path__
),
2
)
self
.
assertEqual
(
len
(
parent
.
child
.
__path__
),
2
)
def
test_project3_succeeds
(
self
):
import
parent.child.one
self
.
assertEqual
(
len
(
parent
.
__path__
),
2
)
self
.
assertEqual
(
len
(
parent
.
child
.
__path__
),
2
)
import
parent.child.two
self
.
assertEqual
(
len
(
parent
.
__path__
),
2
)
self
.
assertEqual
(
len
(
parent
.
child
.
__path__
),
2
)
self
.
assertEqual
(
parent
.
child
.
one
.
attr
,
'parent child one'
)
self
.
assertEqual
(
parent
.
child
.
two
.
attr
,
'parent child two'
)
with
self
.
assertRaises
(
ImportError
):
import
parent.child.three
# now add project3
sys
.
path
.
append
(
os
.
path
.
join
(
self
.
root
,
'project3'
))
import
parent.child.three
# the paths dynamically get longer, to include the new directories
self
.
assertEqual
(
len
(
parent
.
__path__
),
3
)
self
.
assertEqual
(
len
(
parent
.
child
.
__path__
),
3
)
self
.
assertEqual
(
parent
.
child
.
three
.
attr
,
'parent child three'
)
class
ZipWithMissingDirectory
(
NamespacePackageTest
):
paths
=
[
'missing_directory.zip'
]
...
...
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