Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
cb2ecaca
Commit
cb2ecaca
authored
Apr 05, 2010
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finish coverage for App.Extensions.getPath.
parent
a5efa2a3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
0 deletions
+73
-0
src/App/tests/test_Extensions.py
src/App/tests/test_Extensions.py
+73
-0
No files found.
src/App/tests/test_Extensions.py
View file @
cb2ecaca
...
...
@@ -85,6 +85,8 @@ class Test_getPath(unittest.TestCase):
_old_Products___path__
=
None
_tmpdirs
=
()
_old_sys_path
=
None
_added_path
=
None
def
tearDown
(
self
):
import
shutil
...
...
@@ -93,6 +95,12 @@ class Test_getPath(unittest.TestCase):
Products
.
__path__
=
self
.
_old_Products___path__
for
tmpdir
in
self
.
_tmpdirs
:
shutil
.
rmtree
(
tmpdir
)
if
self
.
_old_sys_path
is
not
None
:
import
sys
sys
.
path
[:]
=
self
.
_old_sys_path
for
k
,
v
in
sys
.
modules
.
items
():
if
getattr
(
v
,
'__file__'
,
''
).
startswith
(
self
.
_added_path
):
del
sys
.
modules
[
k
]
def
_callFUT
(
self
,
prefix
,
name
,
checkProduct
=
1
,
suffixes
=
(
''
,),
cfg
=
None
):
from
App.Extensions
import
getPath
...
...
@@ -104,6 +112,14 @@ class Test_getPath(unittest.TestCase):
self
.
_tmpdirs
+=
(
tmp
,)
return
tmp
def
_makePathDir
(
self
):
import
sys
dir
=
self
.
_makeTempdir
()
self
.
_old_sys_path
=
sys
.
path
[:]
sys
.
path
.
insert
(
0
,
dir
)
self
.
_added_path
=
dir
return
dir
def
_makeTempExtension
(
self
,
name
=
'foo'
,
extname
=
'Extensions'
,
dir
=
None
):
import
os
if
dir
is
None
:
...
...
@@ -180,6 +196,63 @@ class Test_getPath(unittest.TestCase):
suffixes
=
(
'py'
,),
cfg
=
cfg
)
self
.
assertEqual
(
path
,
instfqn
)
def
test_not_found_in_instancehome
(
self
):
import
os
instdir
=
self
.
_makeTempdir
()
zopedir
=
self
.
_makeTempdir
()
swdir
=
os
.
path
.
join
(
zopedir
,
'src'
)
os
.
mkdir
(
swdir
)
zopeext
=
self
.
_makeTempExtension
(
name
=
None
,
dir
=
zopedir
)
zopefqn
=
self
.
_makeFile
(
zopeext
,
'extension.py'
)
cfg
=
self
.
_makeConfig
(
instancehome
=
instdir
,
softwarehome
=
swdir
,
)
path
=
self
.
_callFUT
(
'Extensions'
,
'extension'
,
suffixes
=
(
'py'
,),
cfg
=
cfg
)
self
.
assertEqual
(
path
,
zopefqn
)
def
test_no_swhome
(
self
):
instdir
=
self
.
_makeTempdir
()
cfg
=
self
.
_makeConfig
(
instancehome
=
instdir
,
)
extdir
=
self
.
_makeTempProduct
()
path
=
self
.
_callFUT
(
'Extensions'
,
'extension'
,
suffixes
=
(
'py'
,),
cfg
=
cfg
)
self
.
assertEqual
(
path
,
None
)
def
test_search_via_import_one_dot
(
self
):
import
os
instdir
=
self
.
_makeTempdir
()
cfg
=
self
.
_makeConfig
(
instancehome
=
instdir
,
)
pathdir
=
self
.
_makePathDir
()
pkgdir
=
os
.
path
.
join
(
pathdir
,
'somepkg'
)
os
.
mkdir
(
pkgdir
)
self
.
_makeFile
(
pkgdir
,
'__init__.py'
,
'#package'
)
pkgext
=
self
.
_makeTempExtension
(
name
=
None
,
dir
=
pkgdir
)
pkgfqn
=
self
.
_makeFile
(
pkgext
,
'extension.py'
)
path
=
self
.
_callFUT
(
'Extensions'
,
'somepkg.extension'
,
suffixes
=
(
'py'
,),
cfg
=
cfg
)
self
.
assertEqual
(
path
,
pkgfqn
)
def
test_search_via_import_multiple_dots
(
self
):
import
os
instdir
=
self
.
_makeTempdir
()
cfg
=
self
.
_makeConfig
(
instancehome
=
instdir
,
)
pathdir
=
self
.
_makePathDir
()
pkgdir
=
os
.
path
.
join
(
pathdir
,
'somepkg'
)
os
.
mkdir
(
pkgdir
)
self
.
_makeFile
(
pkgdir
,
'__init__.py'
,
'#package'
)
subpkgdir
=
os
.
path
.
join
(
pkgdir
,
'subpkg'
)
os
.
mkdir
(
subpkgdir
)
self
.
_makeFile
(
subpkgdir
,
'__init__.py'
,
'#subpackage'
)
subpkgext
=
self
.
_makeTempExtension
(
name
=
None
,
dir
=
subpkgdir
)
subpkgfqn
=
self
.
_makeFile
(
subpkgext
,
'extension.py'
)
path
=
self
.
_callFUT
(
'Extensions'
,
'somepkg.subpkg.extension'
,
suffixes
=
(
'py'
,),
cfg
=
cfg
)
self
.
assertEqual
(
path
,
subpkgfqn
)
def
test_suite
():
return
unittest
.
TestSuite
((
unittest
.
makeSuite
(
FuncCodeTests
),
...
...
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