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
6220f215
Commit
6220f215
authored
Aug 08, 2010
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replaced failUnless with assertTrue and failIf with assertFalse in tests.
parent
422ab1b6
Changes
63
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
63 changed files
with
703 additions
and
698 deletions
+703
-698
doc/CHANGES.rst
doc/CHANGES.rst
+5
-0
src/App/tests/testImageFile.py
src/App/tests/testImageFile.py
+3
-3
src/App/tests/test_ApplicationManager.py
src/App/tests/test_ApplicationManager.py
+27
-27
src/App/tests/test_Extensions.py
src/App/tests/test_Extensions.py
+14
-14
src/OFS/tests/testAppInitializer.py
src/OFS/tests/testAppInitializer.py
+15
-15
src/OFS/tests/testApplication.py
src/OFS/tests/testApplication.py
+3
-3
src/OFS/tests/testCache.py
src/OFS/tests/testCache.py
+2
-2
src/OFS/tests/testCopySupport.py
src/OFS/tests/testCopySupport.py
+62
-62
src/OFS/tests/testFileAndImage.py
src/OFS/tests/testFileAndImage.py
+14
-14
src/OFS/tests/testHistory.py
src/OFS/tests/testHistory.py
+5
-5
src/OFS/tests/testObjectManager.py
src/OFS/tests/testObjectManager.py
+48
-48
src/OFS/tests/testProperties.py
src/OFS/tests/testProperties.py
+14
-14
src/OFS/tests/testRanges.py
src/OFS/tests/testRanges.py
+18
-18
src/OFS/tests/testSimpleItem.py
src/OFS/tests/testSimpleItem.py
+3
-3
src/OFS/tests/testTraverse.py
src/OFS/tests/testTraverse.py
+13
-13
src/OFS/tests/test_DTMLDocument.py
src/OFS/tests/test_DTMLDocument.py
+3
-3
src/OFS/tests/test_DTMLMethod.py
src/OFS/tests/test_DTMLMethod.py
+3
-3
src/OFS/tests/test_Uninstalled.py
src/OFS/tests/test_Uninstalled.py
+6
-6
src/OFS/tests/test_XMLExportImport.py
src/OFS/tests/test_XMLExportImport.py
+2
-2
src/OFS/tests/test_userfolder.py
src/OFS/tests/test_userfolder.py
+8
-8
src/Products/Five/browser/tests/pages_ftest.txt
src/Products/Five/browser/tests/pages_ftest.txt
+4
-4
src/Products/Five/browser/tests/test_metaconfigure.py
src/Products/Five/browser/tests/test_metaconfigure.py
+7
-7
src/Products/Five/browser/tests/test_pagetemplatefile.py
src/Products/Five/browser/tests/test_pagetemplatefile.py
+17
-17
src/Products/PageTemplates/tests/testExpressions.py
src/Products/PageTemplates/tests/testExpressions.py
+7
-7
src/Products/PageTemplates/tests/testZRPythonExpr.py
src/Products/PageTemplates/tests/testZRPythonExpr.py
+2
-2
src/Products/PageTemplates/tests/testZopePageTemplate.py
src/Products/PageTemplates/tests/testZopePageTemplate.py
+6
-6
src/Products/PageTemplates/tests/test_ptfile.py
src/Products/PageTemplates/tests/test_ptfile.py
+1
-1
src/Products/PluginIndexes/DateIndex/tests/test_DateIndex.py
src/Products/PluginIndexes/DateIndex/tests/test_DateIndex.py
+10
-10
src/Products/PluginIndexes/DateRangeIndex/tests/test_DateRangeIndex.py
...PluginIndexes/DateRangeIndex/tests/test_DateRangeIndex.py
+5
-5
src/Products/PluginIndexes/KeywordIndex/tests/testKeywordIndex.py
...ucts/PluginIndexes/KeywordIndex/tests/testKeywordIndex.py
+6
-6
src/Products/PluginIndexes/PathIndex/tests/testPathIndex.py
src/Products/PluginIndexes/PathIndex/tests/testPathIndex.py
+3
-3
src/Products/Sessions/tests/testBrowserIdManager.py
src/Products/Sessions/tests/testBrowserIdManager.py
+33
-33
src/Products/Sessions/tests/testSessionDataManager.py
src/Products/Sessions/tests/testSessionDataManager.py
+18
-18
src/Products/SiteAccess/tests/testAccessRule.py
src/Products/SiteAccess/tests/testAccessRule.py
+30
-30
src/Products/SiteAccess/tests/testSiteRoot.py
src/Products/SiteAccess/tests/testSiteRoot.py
+15
-15
src/Products/SiteAccess/tests/testVirtualHostMonster.py
src/Products/SiteAccess/tests/testVirtualHostMonster.py
+4
-4
src/Products/Transience/tests/testTransientObject.py
src/Products/Transience/tests/testTransientObject.py
+3
-3
src/Products/Transience/tests/testTransientObjectContainer.py
...Products/Transience/tests/testTransientObjectContainer.py
+4
-4
src/Products/ZCatalog/tests/test_brains.py
src/Products/ZCatalog/tests/test_brains.py
+4
-4
src/Products/ZCatalog/tests/test_zcatalog.py
src/Products/ZCatalog/tests/test_zcatalog.py
+1
-1
src/Products/ZReST/tests/test_ZReST.py
src/Products/ZReST/tests/test_ZReST.py
+3
-3
src/Testing/ZopeTestCase/testFunctional.py
src/Testing/ZopeTestCase/testFunctional.py
+1
-1
src/Testing/ZopeTestCase/testInterfaces.py
src/Testing/ZopeTestCase/testInterfaces.py
+19
-19
src/Testing/ZopeTestCase/testPortalTestCase.py
src/Testing/ZopeTestCase/testPortalTestCase.py
+34
-34
src/Testing/ZopeTestCase/testZODBCompat.py
src/Testing/ZopeTestCase/testZODBCompat.py
+26
-26
src/Testing/ZopeTestCase/testZopeTestCase.py
src/Testing/ZopeTestCase/testZopeTestCase.py
+26
-26
src/Testing/tests/test_makerequest.py
src/Testing/tests/test_makerequest.py
+4
-4
src/ZPublisher/tests/testHTTPRangeSupport.py
src/ZPublisher/tests/testHTTPRangeSupport.py
+3
-3
src/ZPublisher/tests/testHTTPRequest.py
src/ZPublisher/tests/testHTTPRequest.py
+12
-12
src/ZPublisher/tests/testHTTPResponse.py
src/ZPublisher/tests/testHTTPResponse.py
+50
-50
src/ZPublisher/tests/test_WSGIPublisher.py
src/ZPublisher/tests/test_WSGIPublisher.py
+17
-17
src/ZPublisher/tests/test_xmlrpc.py
src/ZPublisher/tests/test_xmlrpc.py
+7
-7
src/ZPublisher/tests/testpubevents.py
src/ZPublisher/tests/testpubevents.py
+1
-1
src/ZServer/tests/test_clockserver.py
src/ZServer/tests/test_clockserver.py
+3
-3
src/ZServer/tests/test_responses.py
src/ZServer/tests/test_responses.py
+1
-1
src/ZTUtils/tests/testTree.py
src/ZTUtils/tests/testTree.py
+1
-1
src/Zope2/App/tests/testExceptionHook.py
src/Zope2/App/tests/testExceptionHook.py
+24
-24
src/Zope2/App/tests/test_schema.py
src/Zope2/App/tests/test_schema.py
+1
-1
src/Zope2/Startup/tests/testStarter.py
src/Zope2/Startup/tests/testStarter.py
+8
-8
src/reStructuredText/tests/testReST.py
src/reStructuredText/tests/testReST.py
+2
-2
src/webdav/tests/testLockable.py
src/webdav/tests/testLockable.py
+5
-5
src/webdav/tests/testNullResource.py
src/webdav/tests/testNullResource.py
+2
-2
src/webdav/tests/testPUT_factory.py
src/webdav/tests/testPUT_factory.py
+5
-5
No files found.
doc/CHANGES.rst
View file @
6220f215
...
@@ -12,6 +12,11 @@ Bugs Fixed
...
@@ -12,6 +12,11 @@ Bugs Fixed
++++++++++
++++++++++
Features Added
++++++++++++++
- Replaced failUnless with assertTrue and failIf with assertFalse in tests.
2.13.0a3 (2010-08-04)
2.13.0a3 (2010-08-04)
---------------------
---------------------
...
...
src/App/tests/testImageFile.py
View file @
6220f215
...
@@ -27,17 +27,17 @@ class TestImageFile(unittest.TestCase):
...
@@ -27,17 +27,17 @@ class TestImageFile(unittest.TestCase):
path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
App
.
__file__
),
path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
App
.
__file__
),
'www'
,
'zopelogo.jpg'
)
'www'
,
'zopelogo.jpg'
)
App
.
ImageFile
.
ImageFile
(
path
)
App
.
ImageFile
.
ImageFile
(
path
)
self
.
failIf
(
self
.
warningshook
.
warnings
)
self
.
assertFalse
(
self
.
warningshook
.
warnings
)
def
test_no_warn_on_path_as_prefix
(
self
):
def
test_no_warn_on_path_as_prefix
(
self
):
prefix
=
os
.
path
.
dirname
(
App
.
__file__
)
prefix
=
os
.
path
.
dirname
(
App
.
__file__
)
App
.
ImageFile
.
ImageFile
(
'www/zopelogo.jpg'
,
prefix
)
App
.
ImageFile
.
ImageFile
(
'www/zopelogo.jpg'
,
prefix
)
self
.
failIf
(
self
.
warningshook
.
warnings
)
self
.
assertFalse
(
self
.
warningshook
.
warnings
)
def
test_no_warn_on_namespace_as_prefix
(
self
):
def
test_no_warn_on_namespace_as_prefix
(
self
):
prefix
=
App
.
__dict__
# same as calling globals() inside the App module
prefix
=
App
.
__dict__
# same as calling globals() inside the App module
App
.
ImageFile
.
ImageFile
(
'www/zopelogo.jpg'
,
prefix
)
App
.
ImageFile
.
ImageFile
(
'www/zopelogo.jpg'
,
prefix
)
self
.
failIf
(
self
.
warningshook
.
warnings
)
self
.
assertFalse
(
self
.
warningshook
.
warnings
)
def
test_suite
():
def
test_suite
():
return
unittest
.
TestSuite
((
return
unittest
.
TestSuite
((
...
...
src/App/tests/test_ApplicationManager.py
View file @
6220f215
...
@@ -31,7 +31,7 @@ class FakeConnectionTests(unittest.TestCase):
...
@@ -31,7 +31,7 @@ class FakeConnectionTests(unittest.TestCase):
db
=
object
()
db
=
object
()
parent_jar
=
object
()
parent_jar
=
object
()
fc
=
self
.
_makeOne
(
db
,
parent_jar
)
fc
=
self
.
_makeOne
(
db
,
parent_jar
)
self
.
failUnless
(
fc
.
db
()
is
db
)
self
.
assertTrue
(
fc
.
db
()
is
db
)
class
DatabaseChooserTests
(
ConfigTestBase
,
unittest
.
TestCase
):
class
DatabaseChooserTests
(
ConfigTestBase
,
unittest
.
TestCase
):
...
@@ -70,12 +70,12 @@ class DatabaseChooserTests(ConfigTestBase, unittest.TestCase):
...
@@ -70,12 +70,12 @@ class DatabaseChooserTests(ConfigTestBase, unittest.TestCase):
root
=
self
.
_makeRoot
()
root
=
self
.
_makeRoot
()
dc
=
self
.
_makeOne
(
'test'
).
__of__
(
root
)
dc
=
self
.
_makeOne
(
'test'
).
__of__
(
root
)
found
=
dc
[
'foo'
]
found
=
dc
[
'foo'
]
self
.
failUnless
(
isinstance
(
found
,
AltDatabaseManager
))
self
.
assertTrue
(
isinstance
(
found
,
AltDatabaseManager
))
self
.
assertEqual
(
found
.
id
,
'foo'
)
self
.
assertEqual
(
found
.
id
,
'foo'
)
self
.
failUnless
(
found
.
aq_parent
is
dc
)
self
.
assertTrue
(
found
.
aq_parent
is
dc
)
conn
=
found
.
_p_jar
conn
=
found
.
_p_jar
self
.
failUnless
(
isinstance
(
conn
,
FakeConnection
))
self
.
assertTrue
(
isinstance
(
conn
,
FakeConnection
))
self
.
failUnless
(
conn
.
db
()
is
foo
)
self
.
assertTrue
(
conn
.
db
()
is
foo
)
def
test___bobo_traverse___miss
(
self
):
def
test___bobo_traverse___miss
(
self
):
self
.
_makeConfig
(
foo
=
object
(),
bar
=
object
(),
qux
=
object
())
self
.
_makeConfig
(
foo
=
object
(),
bar
=
object
(),
qux
=
object
())
...
@@ -93,12 +93,12 @@ class DatabaseChooserTests(ConfigTestBase, unittest.TestCase):
...
@@ -93,12 +93,12 @@ class DatabaseChooserTests(ConfigTestBase, unittest.TestCase):
root
=
self
.
_makeRoot
()
root
=
self
.
_makeRoot
()
dc
=
self
.
_makeOne
(
'test'
).
__of__
(
root
)
dc
=
self
.
_makeOne
(
'test'
).
__of__
(
root
)
found
=
dc
.
__bobo_traverse__
(
None
,
'foo'
)
found
=
dc
.
__bobo_traverse__
(
None
,
'foo'
)
self
.
failUnless
(
isinstance
(
found
,
AltDatabaseManager
))
self
.
assertTrue
(
isinstance
(
found
,
AltDatabaseManager
))
self
.
assertEqual
(
found
.
id
,
'foo'
)
self
.
assertEqual
(
found
.
id
,
'foo'
)
self
.
failUnless
(
found
.
aq_parent
is
dc
)
self
.
assertTrue
(
found
.
aq_parent
is
dc
)
conn
=
found
.
_p_jar
conn
=
found
.
_p_jar
self
.
failUnless
(
isinstance
(
conn
,
FakeConnection
))
self
.
assertTrue
(
isinstance
(
conn
,
FakeConnection
))
self
.
failUnless
(
conn
.
db
()
is
foo
)
self
.
assertTrue
(
conn
.
db
()
is
foo
)
def
test___bobo_traverse___miss_db_hit_attr
(
self
):
def
test___bobo_traverse___miss_db_hit_attr
(
self
):
foo
=
object
()
foo
=
object
()
...
@@ -109,7 +109,7 @@ class DatabaseChooserTests(ConfigTestBase, unittest.TestCase):
...
@@ -109,7 +109,7 @@ class DatabaseChooserTests(ConfigTestBase, unittest.TestCase):
dc
=
self
.
_makeOne
(
'test'
).
__of__
(
root
)
dc
=
self
.
_makeOne
(
'test'
).
__of__
(
root
)
dc
.
spam
=
spam
=
object
()
dc
.
spam
=
spam
=
object
()
found
=
dc
.
__bobo_traverse__
(
None
,
'spam'
)
found
=
dc
.
__bobo_traverse__
(
None
,
'spam'
)
self
.
failUnless
(
found
is
spam
)
self
.
assertTrue
(
found
is
spam
)
def
test_tpValues
(
self
):
def
test_tpValues
(
self
):
from
App.ApplicationManager
import
AltDatabaseManager
from
App.ApplicationManager
import
AltDatabaseManager
...
@@ -121,13 +121,13 @@ class DatabaseChooserTests(ConfigTestBase, unittest.TestCase):
...
@@ -121,13 +121,13 @@ class DatabaseChooserTests(ConfigTestBase, unittest.TestCase):
dc
=
self
.
_makeOne
(
'test'
).
__of__
(
root
)
dc
=
self
.
_makeOne
(
'test'
).
__of__
(
root
)
values
=
dc
.
tpValues
()
values
=
dc
.
tpValues
()
self
.
assertEqual
(
len
(
values
),
3
)
self
.
assertEqual
(
len
(
values
),
3
)
self
.
failUnless
(
isinstance
(
values
[
0
],
AltDatabaseManager
))
self
.
assertTrue
(
isinstance
(
values
[
0
],
AltDatabaseManager
))
self
.
assertEqual
(
values
[
0
].
id
,
'bar'
)
self
.
assertEqual
(
values
[
0
].
id
,
'bar'
)
self
.
assertEqual
(
values
[
0
].
_p_jar
,
None
)
self
.
assertEqual
(
values
[
0
].
_p_jar
,
None
)
self
.
failUnless
(
isinstance
(
values
[
1
],
AltDatabaseManager
))
self
.
assertTrue
(
isinstance
(
values
[
1
],
AltDatabaseManager
))
self
.
assertEqual
(
values
[
1
].
id
,
'foo'
)
self
.
assertEqual
(
values
[
1
].
id
,
'foo'
)
self
.
assertEqual
(
values
[
1
].
_p_jar
,
None
)
self
.
assertEqual
(
values
[
1
].
_p_jar
,
None
)
self
.
failUnless
(
isinstance
(
values
[
2
],
AltDatabaseManager
))
self
.
assertTrue
(
isinstance
(
values
[
2
],
AltDatabaseManager
))
self
.
assertEqual
(
values
[
2
].
id
,
'qux'
)
self
.
assertEqual
(
values
[
2
].
id
,
'qux'
)
self
.
assertEqual
(
values
[
2
].
_p_jar
,
None
)
self
.
assertEqual
(
values
[
2
].
_p_jar
,
None
)
...
@@ -177,11 +177,11 @@ class DebugManagerTests(unittest.TestCase):
...
@@ -177,11 +177,11 @@ class DebugManagerTests(unittest.TestCase):
pairs
=
dm
.
refcount
()
pairs
=
dm
.
refcount
()
# XXX : Ugly empiricism here: I don't know why the count is up 1.
# XXX : Ugly empiricism here: I don't know why the count is up 1.
foo_count
=
sys
.
getrefcount
(
Foo
)
foo_count
=
sys
.
getrefcount
(
Foo
)
self
.
failUnless
((
foo_count
+
1
,
'foo.Foo'
)
in
pairs
)
self
.
assertTrue
((
foo_count
+
1
,
'foo.Foo'
)
in
pairs
)
bar_count
=
sys
.
getrefcount
(
Bar
)
bar_count
=
sys
.
getrefcount
(
Bar
)
self
.
failUnless
((
bar_count
+
1
,
'foo.Bar'
)
in
pairs
)
self
.
assertTrue
((
bar_count
+
1
,
'foo.Bar'
)
in
pairs
)
baz_count
=
sys
.
getrefcount
(
Baz
)
baz_count
=
sys
.
getrefcount
(
Baz
)
self
.
failUnless
((
baz_count
+
1
,
'qux.Baz'
)
in
pairs
)
self
.
assertTrue
((
baz_count
+
1
,
'qux.Baz'
)
in
pairs
)
def
test_refdict
(
self
):
def
test_refdict
(
self
):
import
sys
import
sys
...
@@ -206,7 +206,7 @@ class DebugManagerTests(unittest.TestCase):
...
@@ -206,7 +206,7 @@ class DebugManagerTests(unittest.TestCase):
dm
.
rcsnapshot
()
dm
.
rcsnapshot
()
after
=
DateTime
()
after
=
DateTime
()
# XXX : Ugly empiricism here: I don't know why the count is up 1.
# XXX : Ugly empiricism here: I don't know why the count is up 1.
self
.
failUnless
(
before
<=
App
.
ApplicationManager
.
_v_rst
<=
after
)
self
.
assertTrue
(
before
<=
App
.
ApplicationManager
.
_v_rst
<=
after
)
mapping
=
App
.
ApplicationManager
.
_v_rcs
mapping
=
App
.
ApplicationManager
.
_v_rcs
foo_count
=
sys
.
getrefcount
(
Foo
)
foo_count
=
sys
.
getrefcount
(
Foo
)
self
.
assertEqual
(
mapping
[
'foo.Foo'
],
foo_count
+
1
)
self
.
assertEqual
(
mapping
[
'foo.Foo'
],
foo_count
+
1
)
...
@@ -222,17 +222,17 @@ class DebugManagerTests(unittest.TestCase):
...
@@ -222,17 +222,17 @@ class DebugManagerTests(unittest.TestCase):
dm
=
self
.
_makeOne
(
'test'
)
dm
=
self
.
_makeOne
(
'test'
)
found
=
dm
.
rcdate
()
found
=
dm
.
rcdate
()
App
.
ApplicationManager
.
_v_rst
=
None
App
.
ApplicationManager
.
_v_rst
=
None
self
.
failUnless
(
found
is
dummy
)
self
.
assertTrue
(
found
is
dummy
)
def
test_rcdeltas
(
self
):
def
test_rcdeltas
(
self
):
dm
=
self
.
_makeOne
(
'test'
)
dm
=
self
.
_makeOne
(
'test'
)
dm
.
rcsnapshot
()
dm
.
rcsnapshot
()
Foo
,
Bar
,
Baz
=
self
.
_makeModuleClasses
()
Foo
,
Bar
,
Baz
=
self
.
_makeModuleClasses
()
mappings
=
dm
.
rcdeltas
()
mappings
=
dm
.
rcdeltas
()
self
.
failUnless
(
len
(
mappings
))
self
.
assertTrue
(
len
(
mappings
))
mapping
=
mappings
[
0
]
mapping
=
mappings
[
0
]
self
.
failUnless
(
'rc'
in
mapping
)
self
.
assertTrue
(
'rc'
in
mapping
)
self
.
failUnless
(
'pc'
in
mapping
)
self
.
assertTrue
(
'pc'
in
mapping
)
self
.
assertEqual
(
mapping
[
'delta'
],
mapping
[
'rc'
]
-
mapping
[
'pc'
])
self
.
assertEqual
(
mapping
[
'delta'
],
mapping
[
'rc'
]
-
mapping
[
'pc'
])
#def test_dbconnections(self): XXX -- TOO UGLY TO TEST
#def test_dbconnections(self): XXX -- TOO UGLY TO TEST
...
@@ -252,8 +252,8 @@ class DebugManagerTests(unittest.TestCase):
...
@@ -252,8 +252,8 @@ class DebugManagerTests(unittest.TestCase):
sys
.
_ps_
=
_old_sys__ps_
sys
.
_ps_
=
_old_sys__ps_
if
_old_Publish_pstat
is
not
self
:
if
_old_Publish_pstat
is
not
self
:
Publish
.
_pstat
=
_old_Publish_pstat
Publish
.
_pstat
=
_old_Publish_pstat
self
.
failUnless
(
sys
.
_ps_
is
None
)
self
.
assertTrue
(
sys
.
_ps_
is
None
)
self
.
failUnless
(
Publish
.
_pstat
is
None
)
self
.
assertTrue
(
Publish
.
_pstat
is
None
)
def
test_manage_getSysPath
(
self
):
def
test_manage_getSysPath
(
self
):
import
sys
import
sys
...
@@ -353,11 +353,11 @@ class ApplicationManagerTests(ConfigTestBase,
...
@@ -353,11 +353,11 @@ class ApplicationManagerTests(ConfigTestBase,
def
test_ctor_initializes_Products
(
self
):
def
test_ctor_initializes_Products
(
self
):
from
App.Product
import
ProductFolder
from
App.Product
import
ProductFolder
am
=
self
.
_makeOne
()
am
=
self
.
_makeOne
()
self
.
failUnless
(
isinstance
(
am
.
Products
,
ProductFolder
))
self
.
assertTrue
(
isinstance
(
am
.
Products
,
ProductFolder
))
def
test__canCopy
(
self
):
def
test__canCopy
(
self
):
am
=
self
.
_makeOne
()
am
=
self
.
_makeOne
()
self
.
failIf
(
am
.
_canCopy
())
self
.
assertFalse
(
am
.
_canCopy
())
def
test_manage_app
(
self
):
def
test_manage_app
(
self
):
from
zExceptions
import
Redirect
from
zExceptions
import
Redirect
...
@@ -505,8 +505,8 @@ class ApplicationManagerTests(ConfigTestBase,
...
@@ -505,8 +505,8 @@ class ApplicationManagerTests(ConfigTestBase,
socket_map
.
update
(
_old_socket_map
)
socket_map
.
update
(
_old_socket_map
)
self
.
assertEqual
(
len
(
pairs
),
2
)
self
.
assertEqual
(
len
(
pairs
),
2
)
self
.
failUnless
((
str
(
DummySocketServer
),
'Port: 45'
)
in
pairs
)
self
.
assertTrue
((
str
(
DummySocketServer
),
'Port: 45'
)
in
pairs
)
self
.
failUnless
((
str
(
AnotherSocketServer
),
'Port: 57'
)
in
pairs
)
self
.
assertTrue
((
str
(
AnotherSocketServer
),
'Port: 57'
)
in
pairs
)
#def test_objectIds(self): XXX -- TOO UGLY TO TEST (BBB for Zope 2.3!!)
#def test_objectIds(self): XXX -- TOO UGLY TO TEST (BBB for Zope 2.3!!)
...
...
src/App/tests/test_Extensions.py
View file @
6220f215
...
@@ -56,13 +56,13 @@ class FuncCodeTests(unittest.TestCase):
...
@@ -56,13 +56,13 @@ class FuncCodeTests(unittest.TestCase):
def
f
(
self
):
def
f
(
self
):
pass
pass
fc
=
self
.
_makeOne
(
f
,
im
=
1
)
fc
=
self
.
_makeOne
(
f
,
im
=
1
)
self
.
failUnless
(
cmp
(
fc
,
None
)
>
0
)
self
.
assertTrue
(
cmp
(
fc
,
None
)
>
0
)
def
test___cmp___non_FuncCode
(
self
):
def
test___cmp___non_FuncCode
(
self
):
def
f
(
self
):
def
f
(
self
):
pass
pass
fc
=
self
.
_makeOne
(
f
,
im
=
1
)
fc
=
self
.
_makeOne
(
f
,
im
=
1
)
self
.
failUnless
(
cmp
(
fc
,
object
())
>
0
)
self
.
assertTrue
(
cmp
(
fc
,
object
())
>
0
)
def
test___cmp___w_FuncCode_same_args
(
self
):
def
test___cmp___w_FuncCode_same_args
(
self
):
def
f
(
self
,
a
,
b
):
def
f
(
self
,
a
,
b
):
...
@@ -71,7 +71,7 @@ class FuncCodeTests(unittest.TestCase):
...
@@ -71,7 +71,7 @@ class FuncCodeTests(unittest.TestCase):
pass
pass
fc
=
self
.
_makeOne
(
f
,
im
=
1
)
fc
=
self
.
_makeOne
(
f
,
im
=
1
)
fc2
=
self
.
_makeOne
(
g
,
im
=
1
)
fc2
=
self
.
_makeOne
(
g
,
im
=
1
)
self
.
failUnless
(
cmp
(
fc
,
fc2
)
==
0
)
self
.
assertTrue
(
cmp
(
fc
,
fc2
)
==
0
)
def
test___cmp___w_FuncCode_different_args
(
self
):
def
test___cmp___w_FuncCode_different_args
(
self
):
def
f
(
self
):
def
f
(
self
):
...
@@ -80,7 +80,7 @@ class FuncCodeTests(unittest.TestCase):
...
@@ -80,7 +80,7 @@ class FuncCodeTests(unittest.TestCase):
pass
pass
fc
=
self
.
_makeOne
(
f
,
im
=
1
)
fc
=
self
.
_makeOne
(
f
,
im
=
1
)
fc2
=
self
.
_makeOne
(
g
,
im
=
1
)
fc2
=
self
.
_makeOne
(
g
,
im
=
1
)
self
.
failUnless
(
cmp
(
fc
,
fc2
)
<
0
)
self
.
assertTrue
(
cmp
(
fc
,
fc2
)
<
0
)
class
_TempdirBase
:
class
_TempdirBase
:
...
@@ -317,14 +317,14 @@ class Test_getObject(_TempdirBase, unittest.TestCase):
...
@@ -317,14 +317,14 @@ class Test_getObject(_TempdirBase, unittest.TestCase):
obj
=
object
()
obj
=
object
()
MODULES
=
{
'somemodule'
:
{
'name'
:
obj
}}
MODULES
=
{
'somemodule'
:
{
'name'
:
obj
}}
found
=
self
.
_callFUT
(
'somemodule'
,
'name'
,
modules
=
MODULES
)
found
=
self
.
_callFUT
(
'somemodule'
,
'name'
,
modules
=
MODULES
)
self
.
failUnless
(
found
is
obj
)
self
.
assertTrue
(
found
is
obj
)
def
test_no_such_module
(
self
):
def
test_no_such_module
(
self
):
from
zExceptions
import
NotFound
from
zExceptions
import
NotFound
MODULES
=
{}
MODULES
=
{}
self
.
assertRaises
(
NotFound
,
self
.
_callFUT
,
self
.
assertRaises
(
NotFound
,
self
.
_callFUT
,
'nonesuch'
,
'name'
,
modules
=
MODULES
)
'nonesuch'
,
'name'
,
modules
=
MODULES
)
self
.
failIf
(
'nonesuch'
in
MODULES
)
self
.
assertFalse
(
'nonesuch'
in
MODULES
)
def
test_not_found_in_module
(
self
):
def
test_not_found_in_module
(
self
):
from
zExceptions
import
NotFound
from
zExceptions
import
NotFound
...
@@ -333,8 +333,8 @@ class Test_getObject(_TempdirBase, unittest.TestCase):
...
@@ -333,8 +333,8 @@ class Test_getObject(_TempdirBase, unittest.TestCase):
ext
=
self
.
_makeFile
(
extdir
,
'extension.py'
)
ext
=
self
.
_makeFile
(
extdir
,
'extension.py'
)
self
.
assertRaises
(
NotFound
,
self
.
_callFUT
,
self
.
assertRaises
(
NotFound
,
self
.
_callFUT
,
'foo.extension'
,
'name'
,
modules
=
MODULES
)
'foo.extension'
,
'name'
,
modules
=
MODULES
)
self
.
failUnless
(
'foo.extension'
in
MODULES
)
self
.
assertTrue
(
'foo.extension'
in
MODULES
)
self
.
failIf
(
'named'
in
MODULES
[
'foo.extension'
])
self
.
assertFalse
(
'named'
in
MODULES
[
'foo.extension'
])
def
test_found_in_module
(
self
):
def
test_found_in_module
(
self
):
MODULES
=
{}
MODULES
=
{}
...
@@ -342,7 +342,7 @@ class Test_getObject(_TempdirBase, unittest.TestCase):
...
@@ -342,7 +342,7 @@ class Test_getObject(_TempdirBase, unittest.TestCase):
ext
=
self
.
_makeFile
(
extdir
,
'extension.py'
,
EXTENSION_PY
)
ext
=
self
.
_makeFile
(
extdir
,
'extension.py'
,
EXTENSION_PY
)
found
=
self
.
_callFUT
(
'foo.extension'
,
'named'
,
modules
=
MODULES
)
found
=
self
.
_callFUT
(
'foo.extension'
,
'named'
,
modules
=
MODULES
)
self
.
assertEqual
(
found
,
'NAMED'
)
self
.
assertEqual
(
found
,
'NAMED'
)
self
.
failUnless
(
'foo.extension'
in
MODULES
)
self
.
assertTrue
(
'foo.extension'
in
MODULES
)
self
.
assertEqual
(
MODULES
[
'foo.extension'
][
'named'
],
'NAMED'
)
self
.
assertEqual
(
MODULES
[
'foo.extension'
][
'named'
],
'NAMED'
)
def
test_found_in_module_pyc
(
self
):
def
test_found_in_module_pyc
(
self
):
...
@@ -355,7 +355,7 @@ class Test_getObject(_TempdirBase, unittest.TestCase):
...
@@ -355,7 +355,7 @@ class Test_getObject(_TempdirBase, unittest.TestCase):
os
.
remove
(
ext
)
os
.
remove
(
ext
)
found
=
self
.
_callFUT
(
'foo.extension'
,
'named'
,
modules
=
MODULES
)
found
=
self
.
_callFUT
(
'foo.extension'
,
'named'
,
modules
=
MODULES
)
self
.
assertEqual
(
found
,
'NAMED'
)
self
.
assertEqual
(
found
,
'NAMED'
)
self
.
failUnless
(
'foo.extension'
in
MODULES
)
self
.
assertTrue
(
'foo.extension'
in
MODULES
)
self
.
assertEqual
(
MODULES
[
'foo.extension'
][
'named'
],
'NAMED'
)
self
.
assertEqual
(
MODULES
[
'foo.extension'
][
'named'
],
'NAMED'
)
def
test_found_in_module_after_cache_miss
(
self
):
def
test_found_in_module_after_cache_miss
(
self
):
...
@@ -388,26 +388,26 @@ class Test_getBrain(_TempdirBase, unittest.TestCase):
...
@@ -388,26 +388,26 @@ class Test_getBrain(_TempdirBase, unittest.TestCase):
def
test_no_module_no_class_yields_NoBrains
(
self
):
def
test_no_module_no_class_yields_NoBrains
(
self
):
from
App.Extensions
import
NoBrains
from
App.Extensions
import
NoBrains
self
.
failUnless
(
self
.
_callFUT
(
''
,
''
)
is
NoBrains
)
self
.
assertTrue
(
self
.
_callFUT
(
''
,
''
)
is
NoBrains
)
def
test_missing_name
(
self
):
def
test_missing_name
(
self
):
from
App.Extensions
import
NoBrains
from
App.Extensions
import
NoBrains
from
zExceptions
import
NotFound
from
zExceptions
import
NotFound
self
.
failUnless
(
self
.
_callFUT
(
''
,
''
)
is
NoBrains
)
self
.
assertTrue
(
self
.
_callFUT
(
''
,
''
)
is
NoBrains
)
MODULES
=
{
'somemodule'
:
{}}
MODULES
=
{
'somemodule'
:
{}}
self
.
assertRaises
(
NotFound
,
self
.
assertRaises
(
NotFound
,
self
.
_callFUT
,
'somemodule'
,
'name'
,
modules
=
MODULES
)
self
.
_callFUT
,
'somemodule'
,
'name'
,
modules
=
MODULES
)
def
test_not_a_class
(
self
):
def
test_not_a_class
(
self
):
from
App.Extensions
import
NoBrains
from
App.Extensions
import
NoBrains
self
.
failUnless
(
self
.
_callFUT
(
''
,
''
)
is
NoBrains
)
self
.
assertTrue
(
self
.
_callFUT
(
''
,
''
)
is
NoBrains
)
MODULES
=
{
'somemodule'
:
{
'name'
:
object
()}}
MODULES
=
{
'somemodule'
:
{
'name'
:
object
()}}
self
.
assertRaises
(
ValueError
,
self
.
assertRaises
(
ValueError
,
self
.
_callFUT
,
'somemodule'
,
'name'
,
modules
=
MODULES
)
self
.
_callFUT
,
'somemodule'
,
'name'
,
modules
=
MODULES
)
def
test_found_class
(
self
):
def
test_found_class
(
self
):
from
App.Extensions
import
NoBrains
from
App.Extensions
import
NoBrains
self
.
failUnless
(
self
.
_callFUT
(
''
,
''
)
is
NoBrains
)
self
.
assertTrue
(
self
.
_callFUT
(
''
,
''
)
is
NoBrains
)
MODULES
=
{
'somemodule'
:
{
'name'
:
self
.
__class__
}}
MODULES
=
{
'somemodule'
:
{
'name'
:
self
.
__class__
}}
self
.
assertEqual
(
self
.
_callFUT
(
'somemodule'
,
'name'
,
modules
=
MODULES
),
self
.
assertEqual
(
self
.
_callFUT
(
'somemodule'
,
'name'
,
modules
=
MODULES
),
self
.
__class__
)
self
.
__class__
)
...
...
src/OFS/tests/testAppInitializer.py
View file @
6220f215
...
@@ -98,9 +98,9 @@ class TestInitialization( unittest.TestCase ):
...
@@ -98,9 +98,9 @@ class TestInitialization( unittest.TestCase ):
i
=
self
.
getOne
()
i
=
self
.
getOne
()
app
=
i
.
getApp
()
app
=
i
.
getApp
()
i
.
install_cp_and_products
()
i
.
install_cp_and_products
()
self
.
failUnless
(
hasattr
(
app
,
'Control_Panel'
))
self
.
assertTrue
(
hasattr
(
app
,
'Control_Panel'
))
self
.
assertEqual
(
app
.
Control_Panel
.
meta_type
,
'Control Panel'
)
self
.
assertEqual
(
app
.
Control_Panel
.
meta_type
,
'Control Panel'
)
self
.
failUnless
(
hasattr
(
app
.
Control_Panel
,
'Products'
))
self
.
assertTrue
(
hasattr
(
app
.
Control_Panel
,
'Products'
))
self
.
assertEqual
(
app
.
Control_Panel
.
Products
.
meta_type
,
self
.
assertEqual
(
app
.
Control_Panel
.
Products
.
meta_type
,
'Product Management'
)
'Product Management'
)
...
@@ -112,13 +112,13 @@ class TestInitialization( unittest.TestCase ):
...
@@ -112,13 +112,13 @@ class TestInitialization( unittest.TestCase ):
self
.
assertEqual
(
app
.
temp_folder
.
meta_type
,
'Temporary Folder'
)
self
.
assertEqual
(
app
.
temp_folder
.
meta_type
,
'Temporary Folder'
)
self
.
assertEqual
(
app
.
temp_folder
.
session_data
.
meta_type
,
self
.
assertEqual
(
app
.
temp_folder
.
session_data
.
meta_type
,
'Transient Object Container'
)
'Transient Object Container'
)
self
.
failUnless
(
app
.
_getInitializerFlag
(
'temp_folder'
))
self
.
assertTrue
(
app
.
_getInitializerFlag
(
'temp_folder'
))
def
test_install_tempfolder_and_sdc_status
(
self
):
def
test_install_tempfolder_and_sdc_status
(
self
):
self
.
configure
(
good_cfg
)
self
.
configure
(
good_cfg
)
i
=
self
.
getOne
()
i
=
self
.
getOne
()
status
=
i
.
install_tempfolder_and_sdc
()
status
=
i
.
install_tempfolder_and_sdc
()
self
.
failUnless
(
status
)
self
.
assertTrue
(
status
)
i
=
self
.
getOne
()
i
=
self
.
getOne
()
self
.
configure
(
bad_cfg
)
self
.
configure
(
bad_cfg
)
...
@@ -128,7 +128,7 @@ class TestInitialization( unittest.TestCase ):
...
@@ -128,7 +128,7 @@ class TestInitialization( unittest.TestCase ):
status
=
i
.
install_tempfolder_and_sdc
()
status
=
i
.
install_tempfolder_and_sdc
()
finally
:
finally
:
logger
.
disabled
=
0
logger
.
disabled
=
0
self
.
failIf
(
status
)
self
.
assertFalse
(
status
)
def
test_install_tempfolder_and_sdc_unlimited_sessions
(
self
):
def
test_install_tempfolder_and_sdc_unlimited_sessions
(
self
):
unlimited_cfg
=
good_cfg
+
"""
unlimited_cfg
=
good_cfg
+
"""
...
@@ -137,7 +137,7 @@ class TestInitialization( unittest.TestCase ):
...
@@ -137,7 +137,7 @@ class TestInitialization( unittest.TestCase ):
self
.
configure
(
unlimited_cfg
)
self
.
configure
(
unlimited_cfg
)
i
=
self
.
getOne
()
i
=
self
.
getOne
()
status
=
i
.
install_tempfolder_and_sdc
()
status
=
i
.
install_tempfolder_and_sdc
()
self
.
failUnless
(
status
)
self
.
assertTrue
(
status
)
sdc
=
i
.
getApp
().
temp_folder
.
session_data
sdc
=
i
.
getApp
().
temp_folder
.
session_data
self
.
assertEqual
(
sdc
.
getSubobjectLimit
(),
0
)
self
.
assertEqual
(
sdc
.
getSubobjectLimit
(),
0
)
...
@@ -148,7 +148,7 @@ class TestInitialization( unittest.TestCase ):
...
@@ -148,7 +148,7 @@ class TestInitialization( unittest.TestCase ):
app
=
i
.
getApp
()
app
=
i
.
getApp
()
i
.
install_browser_id_manager
()
i
.
install_browser_id_manager
()
self
.
assertEqual
(
app
.
browser_id_manager
.
meta_type
,
'Browser Id Manager'
)
self
.
assertEqual
(
app
.
browser_id_manager
.
meta_type
,
'Browser Id Manager'
)
self
.
failUnless
(
app
.
_getInitializerFlag
(
'browser_id_manager'
))
self
.
assertTrue
(
app
.
_getInitializerFlag
(
'browser_id_manager'
))
def
test_install_virtual_hosting
(
self
):
def
test_install_virtual_hosting
(
self
):
self
.
configure
(
good_cfg
)
self
.
configure
(
good_cfg
)
...
@@ -156,7 +156,7 @@ class TestInitialization( unittest.TestCase ):
...
@@ -156,7 +156,7 @@ class TestInitialization( unittest.TestCase ):
app
=
i
.
getApp
()
app
=
i
.
getApp
()
i
.
install_virtual_hosting
()
i
.
install_virtual_hosting
()
self
.
assertEqual
(
app
.
virtual_hosting
.
meta_type
,
'Virtual Host Monster'
)
self
.
assertEqual
(
app
.
virtual_hosting
.
meta_type
,
'Virtual Host Monster'
)
self
.
failUnless
(
app
.
_getInitializerFlag
(
'virtual_hosting'
))
self
.
assertTrue
(
app
.
_getInitializerFlag
(
'virtual_hosting'
))
def
test_install_session_data_manager
(
self
):
def
test_install_session_data_manager
(
self
):
self
.
configure
(
good_cfg
)
self
.
configure
(
good_cfg
)
...
@@ -165,15 +165,15 @@ class TestInitialization( unittest.TestCase ):
...
@@ -165,15 +165,15 @@ class TestInitialization( unittest.TestCase ):
app
=
i
.
getApp
()
app
=
i
.
getApp
()
self
.
assertEqual
(
app
.
session_data_manager
.
meta_type
,
self
.
assertEqual
(
app
.
session_data_manager
.
meta_type
,
'Session Data Manager'
)
'Session Data Manager'
)
self
.
failUnless
(
app
.
_getInitializerFlag
(
'session_data_manager'
))
self
.
assertTrue
(
app
.
_getInitializerFlag
(
'session_data_manager'
))
def
test_install_required_roles
(
self
):
def
test_install_required_roles
(
self
):
self
.
configure
(
good_cfg
)
self
.
configure
(
good_cfg
)
i
=
self
.
getOne
()
i
=
self
.
getOne
()
i
.
install_required_roles
()
i
.
install_required_roles
()
app
=
i
.
getApp
()
app
=
i
.
getApp
()
self
.
failUnless
(
'Owner'
in
app
.
__ac_roles__
)
self
.
assertTrue
(
'Owner'
in
app
.
__ac_roles__
)
self
.
failUnless
(
'Authenticated'
in
app
.
__ac_roles__
)
self
.
assertTrue
(
'Authenticated'
in
app
.
__ac_roles__
)
def
test_install_inituser
(
self
):
def
test_install_inituser
(
self
):
fname
=
os
.
path
.
join
(
TEMPNAME
,
'inituser'
)
fname
=
os
.
path
.
join
(
TEMPNAME
,
'inituser'
)
...
@@ -185,7 +185,7 @@ class TestInitialization( unittest.TestCase ):
...
@@ -185,7 +185,7 @@ class TestInitialization( unittest.TestCase ):
i
=
self
.
getOne
()
i
=
self
.
getOne
()
i
.
install_inituser
()
i
.
install_inituser
()
app
=
i
.
getApp
()
app
=
i
.
getApp
()
self
.
failUnless
(
app
.
acl_users
.
getUser
(
'theuser'
))
self
.
assertTrue
(
app
.
acl_users
.
getUser
(
'theuser'
))
finally
:
finally
:
if
os
.
path
.
exists
(
fname
):
if
os
.
path
.
exists
(
fname
):
os
.
unlink
(
fname
)
os
.
unlink
(
fname
)
...
@@ -196,13 +196,13 @@ class TestInitialization( unittest.TestCase ):
...
@@ -196,13 +196,13 @@ class TestInitialization( unittest.TestCase ):
i
.
install_errorlog
()
i
.
install_errorlog
()
app
=
i
.
getApp
()
app
=
i
.
getApp
()
self
.
assertEqual
(
app
.
error_log
.
meta_type
,
'Site Error Log'
)
self
.
assertEqual
(
app
.
error_log
.
meta_type
,
'Site Error Log'
)
self
.
failUnless
(
app
.
_getInitializerFlag
(
'error_log'
))
self
.
assertTrue
(
app
.
_getInitializerFlag
(
'error_log'
))
def
test_install_products
(
self
):
def
test_install_products
(
self
):
self
.
configure
(
good_cfg
)
self
.
configure
(
good_cfg
)
i
=
self
.
getOne
()
i
=
self
.
getOne
()
i
.
install_products
()
i
.
install_products
()
self
.
failUnless
(
Application
.
misc_
.
__dict__
.
has_key
(
'OFSP'
))
self
.
assertTrue
(
Application
.
misc_
.
__dict__
.
has_key
(
'OFSP'
))
def
test_install_standards
(
self
):
def
test_install_standards
(
self
):
self
.
configure
(
good_cfg
)
self
.
configure
(
good_cfg
)
...
@@ -212,7 +212,7 @@ class TestInitialization( unittest.TestCase ):
...
@@ -212,7 +212,7 @@ class TestInitialization( unittest.TestCase ):
app
=
i
.
getApp
()
app
=
i
.
getApp
()
self
.
assertEqual
(
app
.
index_html
.
meta_type
,
'Page Template'
)
self
.
assertEqual
(
app
.
index_html
.
meta_type
,
'Page Template'
)
self
.
assertEqual
(
app
.
standard_error_message
.
meta_type
,
'DTML Method'
)
self
.
assertEqual
(
app
.
standard_error_message
.
meta_type
,
'DTML Method'
)
self
.
failUnless
(
hasattr
(
app
,
'_standard_objects_have_been_added'
))
self
.
assertTrue
(
hasattr
(
app
,
'_standard_objects_have_been_added'
))
def
test_suite
():
def
test_suite
():
...
...
src/OFS/tests/testApplication.py
View file @
6220f215
...
@@ -24,7 +24,7 @@ class ApplicationTests(unittest.TestCase):
...
@@ -24,7 +24,7 @@ class ApplicationTests(unittest.TestCase):
def
test_instance_attributes
(
self
):
def
test_instance_attributes
(
self
):
app
=
self
.
_makeOne
()
app
=
self
.
_makeOne
()
self
.
failUnless
(
app
.
isTopLevelPrincipiaApplicationObject
)
self
.
assertTrue
(
app
.
isTopLevelPrincipiaApplicationObject
)
self
.
assertEqual
(
app
.
title
,
'Zope'
)
self
.
assertEqual
(
app
.
title
,
'Zope'
)
def
test_id_no_request
(
self
):
def
test_id_no_request
(
self
):
...
@@ -99,8 +99,8 @@ class ApplicationTests(unittest.TestCase):
...
@@ -99,8 +99,8 @@ class ApplicationTests(unittest.TestCase):
result
=
app
.
__bobo_traverse__
(
request
,
'OTHER'
)
result
=
app
.
__bobo_traverse__
(
request
,
'OTHER'
)
self
.
failUnless
(
isinstance
(
result
,
NullResource
))
self
.
assertTrue
(
isinstance
(
result
,
NullResource
))
self
.
failUnless
(
aq_parent
(
aq_inner
(
result
))
is
app
)
self
.
assertTrue
(
aq_parent
(
aq_inner
(
result
))
is
app
)
def
_noWay
(
self
,
key
,
default
=
None
):
def
_noWay
(
self
,
key
,
default
=
None
):
raise
KeyError
(
key
)
raise
KeyError
(
key
)
...
...
src/OFS/tests/testCache.py
View file @
6220f215
...
@@ -25,13 +25,13 @@ class CacheTests(unittest.TestCase):
...
@@ -25,13 +25,13 @@ class CacheTests(unittest.TestCase):
# To begin with, cache managers will be found correctly
# To begin with, cache managers will be found correctly
# using managersExist
# using managersExist
self
.
failUnless
(
managersExist
(
root
.
child
.
child_content
))
self
.
assertTrue
(
managersExist
(
root
.
child
.
child_content
))
# Now we delete the cache in the child folder
# Now we delete the cache in the child folder
root
.
child
.
manage_delObjects
([
'child_cache'
])
root
.
child
.
manage_delObjects
([
'child_cache'
])
# The parent_cache should still trigger managersExist
# The parent_cache should still trigger managersExist
self
.
failUnless
(
managersExist
(
root
.
child
.
child_content
))
self
.
assertTrue
(
managersExist
(
root
.
child
.
child_content
))
def
test_suite
():
def
test_suite
():
...
...
src/OFS/tests/testCopySupport.py
View file @
6220f215
This diff is collapsed.
Click to expand it.
src/OFS/tests/testFileAndImage.py
View file @
6220f215
...
@@ -152,10 +152,10 @@ class FileTests(unittest.TestCase):
...
@@ -152,10 +152,10 @@ class FileTests(unittest.TestCase):
# Since we do the create here, let's test the events here too
# Since we do the create here, let's test the events here too
self
.
assertEquals
(
1
,
len
(
self
.
eventCatcher
.
created
))
self
.
assertEquals
(
1
,
len
(
self
.
eventCatcher
.
created
))
self
.
failUnless
(
aq_base
(
self
.
eventCatcher
.
created
[
0
].
object
)
is
aq_base
(
self
.
file
))
self
.
assertTrue
(
aq_base
(
self
.
eventCatcher
.
created
[
0
].
object
)
is
aq_base
(
self
.
file
))
self
.
assertEquals
(
1
,
len
(
self
.
eventCatcher
.
modified
))
self
.
assertEquals
(
1
,
len
(
self
.
eventCatcher
.
modified
))
self
.
failUnless
(
aq_base
(
self
.
eventCatcher
.
created
[
0
].
object
)
is
aq_base
(
self
.
file
))
self
.
assertTrue
(
aq_base
(
self
.
eventCatcher
.
created
[
0
].
object
)
is
aq_base
(
self
.
file
))
self
.
eventCatcher
.
reset
()
self
.
eventCatcher
.
reset
()
...
@@ -178,14 +178,14 @@ class FileTests(unittest.TestCase):
...
@@ -178,14 +178,14 @@ class FileTests(unittest.TestCase):
self
.
file
.
update_data
(
'foo'
)
self
.
file
.
update_data
(
'foo'
)
self
.
assertEqual
(
self
.
file
.
size
,
3
)
self
.
assertEqual
(
self
.
file
.
size
,
3
)
self
.
assertEqual
(
self
.
file
.
data
,
'foo'
)
self
.
assertEqual
(
self
.
file
.
data
,
'foo'
)
self
.
failUnless
(
ADummyCache
.
invalidated
)
self
.
assertTrue
(
ADummyCache
.
invalidated
)
self
.
failUnless
(
ADummyCache
.
set
)
self
.
assertTrue
(
ADummyCache
.
set
)
def
testReadData
(
self
):
def
testReadData
(
self
):
s
=
"a"
*
(
2
<<
16
)
s
=
"a"
*
(
2
<<
16
)
f
=
StringIO
(
s
)
f
=
StringIO
(
s
)
data
,
size
=
self
.
file
.
_read_data
(
f
)
data
,
size
=
self
.
file
.
_read_data
(
f
)
self
.
failUnless
(
isinstance
(
data
,
Pdata
))
self
.
assertTrue
(
isinstance
(
data
,
Pdata
))
self
.
assertEqual
(
str
(
data
),
s
)
self
.
assertEqual
(
str
(
data
),
s
)
self
.
assertEqual
(
len
(
s
),
len
(
str
(
data
)))
self
.
assertEqual
(
len
(
s
),
len
(
str
(
data
)))
self
.
assertEqual
(
len
(
s
),
size
)
self
.
assertEqual
(
len
(
s
),
size
)
...
@@ -204,18 +204,18 @@ class FileTests(unittest.TestCase):
...
@@ -204,18 +204,18 @@ class FileTests(unittest.TestCase):
self
.
file
.
manage_edit
(
'foobar'
,
'text/plain'
,
filedata
=
'ASD'
)
self
.
file
.
manage_edit
(
'foobar'
,
'text/plain'
,
filedata
=
'ASD'
)
self
.
assertEqual
(
self
.
file
.
title
,
'foobar'
)
self
.
assertEqual
(
self
.
file
.
title
,
'foobar'
)
self
.
assertEqual
(
self
.
file
.
content_type
,
'text/plain'
)
self
.
assertEqual
(
self
.
file
.
content_type
,
'text/plain'
)
self
.
failUnless
(
ADummyCache
.
invalidated
)
self
.
assertTrue
(
ADummyCache
.
invalidated
)
self
.
failUnless
(
ADummyCache
.
set
)
self
.
assertTrue
(
ADummyCache
.
set
)
self
.
assertEquals
(
1
,
len
(
self
.
eventCatcher
.
modified
))
self
.
assertEquals
(
1
,
len
(
self
.
eventCatcher
.
modified
))
self
.
failUnless
(
self
.
eventCatcher
.
modified
[
0
].
object
is
self
.
file
)
self
.
assertTrue
(
self
.
eventCatcher
.
modified
[
0
].
object
is
self
.
file
)
def
testManageEditWithoutFileData
(
self
):
def
testManageEditWithoutFileData
(
self
):
self
.
file
.
manage_edit
(
'foobar'
,
'text/plain'
)
self
.
file
.
manage_edit
(
'foobar'
,
'text/plain'
)
self
.
assertEqual
(
self
.
file
.
title
,
'foobar'
)
self
.
assertEqual
(
self
.
file
.
title
,
'foobar'
)
self
.
assertEqual
(
self
.
file
.
content_type
,
'text/plain'
)
self
.
assertEqual
(
self
.
file
.
content_type
,
'text/plain'
)
self
.
failUnless
(
ADummyCache
.
invalidated
)
self
.
assertTrue
(
ADummyCache
.
invalidated
)
self
.
assertEquals
(
1
,
len
(
self
.
eventCatcher
.
modified
))
self
.
assertEquals
(
1
,
len
(
self
.
eventCatcher
.
modified
))
self
.
failUnless
(
self
.
eventCatcher
.
modified
[
0
].
object
is
self
.
file
)
self
.
assertTrue
(
self
.
eventCatcher
.
modified
[
0
].
object
is
self
.
file
)
def
testManageUpload
(
self
):
def
testManageUpload
(
self
):
f
=
StringIO
(
'jammyjohnson'
)
f
=
StringIO
(
'jammyjohnson'
)
...
@@ -223,7 +223,7 @@ class FileTests(unittest.TestCase):
...
@@ -223,7 +223,7 @@ class FileTests(unittest.TestCase):
self
.
assertEqual
(
self
.
file
.
data
,
'jammyjohnson'
)
self
.
assertEqual
(
self
.
file
.
data
,
'jammyjohnson'
)
self
.
assertEqual
(
self
.
file
.
content_type
,
'application/octet-stream'
)
self
.
assertEqual
(
self
.
file
.
content_type
,
'application/octet-stream'
)
self
.
assertEquals
(
1
,
len
(
self
.
eventCatcher
.
modified
))
self
.
assertEquals
(
1
,
len
(
self
.
eventCatcher
.
modified
))
self
.
failUnless
(
self
.
eventCatcher
.
modified
[
0
].
object
is
self
.
file
)
self
.
assertTrue
(
self
.
eventCatcher
.
modified
[
0
].
object
is
self
.
file
)
def
testIfModSince
(
self
):
def
testIfModSince
(
self
):
now
=
time
.
time
()
now
=
time
.
time
()
...
@@ -292,7 +292,7 @@ class FileTests(unittest.TestCase):
...
@@ -292,7 +292,7 @@ class FileTests(unittest.TestCase):
self
.
file
.
manage_edit
(
'foobar'
,
'text/plain'
,
self
.
file
.
manage_edit
(
'foobar'
,
'text/plain'
,
filedata
=
'Now is the time for all good men to '
filedata
=
'Now is the time for all good men to '
'come to the aid of the Party.'
)
'come to the aid of the Party.'
)
self
.
failUnless
(
'Party'
in
self
.
file
.
PrincipiaSearchSource
())
self
.
assertTrue
(
'Party'
in
self
.
file
.
PrincipiaSearchSource
())
def
testFindFile
(
self
):
def
testFindFile
(
self
):
self
.
file
.
manage_edit
(
'foobar'
,
'text/plain'
,
self
.
file
.
manage_edit
(
'foobar'
,
'text/plain'
,
...
@@ -328,8 +328,8 @@ class ImageTests(FileTests):
...
@@ -328,8 +328,8 @@ class ImageTests(FileTests):
self
.
assertEqual
(
self
.
file
.
data
,
self
.
data
)
self
.
assertEqual
(
self
.
file
.
data
,
self
.
data
)
self
.
assertEqual
(
self
.
file
.
width
,
16
)
self
.
assertEqual
(
self
.
file
.
width
,
16
)
self
.
assertEqual
(
self
.
file
.
height
,
16
)
self
.
assertEqual
(
self
.
file
.
height
,
16
)
self
.
failUnless
(
ADummyCache
.
invalidated
)
self
.
assertTrue
(
ADummyCache
.
invalidated
)
self
.
failUnless
(
ADummyCache
.
set
)
self
.
assertTrue
(
ADummyCache
.
set
)
def
testStr
(
self
):
def
testStr
(
self
):
self
.
assertEqual
(
str
(
self
.
file
),
self
.
assertEqual
(
str
(
self
.
file
),
...
...
src/OFS/tests/testHistory.py
View file @
6220f215
...
@@ -70,14 +70,14 @@ class HistoryTests(unittest.TestCase):
...
@@ -70,14 +70,14 @@ class HistoryTests(unittest.TestCase):
self
.
assertEqual
(
len
(
entry
.
keys
()),
6
)
self
.
assertEqual
(
len
(
entry
.
keys
()),
6
)
# the transactions are in newest-first order
# the transactions are in newest-first order
self
.
assertEqual
(
entry
[
'description'
],
'Change %i'
%
(
3
-
i
))
self
.
assertEqual
(
entry
[
'description'
],
'Change %i'
%
(
3
-
i
))
self
.
failUnless
(
'key'
in
entry
)
self
.
assertTrue
(
'key'
in
entry
)
# lets not assume the size will stay the same forever
# lets not assume the size will stay the same forever
self
.
failUnless
(
'size'
in
entry
)
self
.
assertTrue
(
'size'
in
entry
)
self
.
failUnless
(
'tid'
in
entry
)
self
.
assertTrue
(
'tid'
in
entry
)
self
.
failUnless
(
'time'
in
entry
)
self
.
assertTrue
(
'time'
in
entry
)
if
i
:
if
i
:
# check times are increasing
# check times are increasing
self
.
failUnless
(
entry
[
'time'
]
<
r
[
i
-
1
][
'time'
])
self
.
assertTrue
(
entry
[
'time'
]
<
r
[
i
-
1
][
'time'
])
self
.
assertEqual
(
entry
[
'user_name'
],
''
)
self
.
assertEqual
(
entry
[
'user_name'
],
''
)
def
test_manage_historyCopy
(
self
):
def
test_manage_historyCopy
(
self
):
...
...
src/OFS/tests/testObjectManager.py
View file @
6220f215
...
@@ -284,20 +284,20 @@ class ObjectManagerTests(PlacelessSetup, unittest.TestCase):
...
@@ -284,20 +284,20 @@ class ObjectManagerTests(PlacelessSetup, unittest.TestCase):
def
test_hasObject
(
self
):
def
test_hasObject
(
self
):
om
=
self
.
_makeOne
()
om
=
self
.
_makeOne
()
self
.
failIf
(
om
.
hasObject
(
'_properties'
))
self
.
assertFalse
(
om
.
hasObject
(
'_properties'
))
self
.
failIf
(
om
.
hasObject
(
'_getOb'
))
self
.
assertFalse
(
om
.
hasObject
(
'_getOb'
))
self
.
failIf
(
om
.
hasObject
(
'__of__'
))
self
.
assertFalse
(
om
.
hasObject
(
'__of__'
))
self
.
failIf
(
om
.
hasObject
(
'.'
))
self
.
assertFalse
(
om
.
hasObject
(
'.'
))
self
.
failIf
(
om
.
hasObject
(
'..'
))
self
.
assertFalse
(
om
.
hasObject
(
'..'
))
self
.
failIf
(
om
.
hasObject
(
'aq_base'
))
self
.
assertFalse
(
om
.
hasObject
(
'aq_base'
))
om
.
zap__
=
True
om
.
zap__
=
True
self
.
failIf
(
om
.
hasObject
(
'zap__'
))
self
.
assertFalse
(
om
.
hasObject
(
'zap__'
))
self
.
failIf
(
om
.
hasObject
(
'foo'
))
self
.
assertFalse
(
om
.
hasObject
(
'foo'
))
si
=
SimpleItem
(
'foo'
)
si
=
SimpleItem
(
'foo'
)
om
.
_setObject
(
'foo'
,
si
)
om
.
_setObject
(
'foo'
,
si
)
self
.
assert_
(
om
.
hasObject
(
'foo'
))
self
.
assert_
(
om
.
hasObject
(
'foo'
))
om
.
_delObject
(
'foo'
)
om
.
_delObject
(
'foo'
)
self
.
failIf
(
om
.
hasObject
(
'foo'
))
self
.
assertFalse
(
om
.
hasObject
(
'foo'
))
def
test_setObject_checkId_ok
(
self
):
def
test_setObject_checkId_ok
(
self
):
om
=
self
.
_makeOne
()
om
=
self
.
_makeOne
()
...
@@ -338,13 +338,13 @@ class ObjectManagerTests(PlacelessSetup, unittest.TestCase):
...
@@ -338,13 +338,13 @@ class ObjectManagerTests(PlacelessSetup, unittest.TestCase):
si1
=
SimpleItem
(
'1'
)
si1
=
SimpleItem
(
'1'
)
si2
=
SimpleItem
(
'2'
)
si2
=
SimpleItem
(
'2'
)
om
[
'1'
]
=
si1
om
[
'1'
]
=
si1
self
.
failUnless
(
'1'
in
om
)
self
.
assertTrue
(
'1'
in
om
)
self
.
failUnless
(
si1
in
om
.
objectValues
())
self
.
assertTrue
(
si1
in
om
.
objectValues
())
self
.
failUnless
(
'1'
in
om
.
objectIds
())
self
.
assertTrue
(
'1'
in
om
.
objectIds
())
om
[
'2'
]
=
si2
om
[
'2'
]
=
si2
self
.
failUnless
(
'2'
in
om
)
self
.
assertTrue
(
'2'
in
om
)
self
.
failUnless
(
si2
in
om
.
objectValues
())
self
.
assertTrue
(
si2
in
om
.
objectValues
())
self
.
failUnless
(
'2'
in
om
.
objectIds
())
self
.
assertTrue
(
'2'
in
om
.
objectIds
())
self
.
assertRaises
(
BadRequest
,
om
.
_setObject
,
'1'
,
si2
)
self
.
assertRaises
(
BadRequest
,
om
.
_setObject
,
'1'
,
si2
)
self
.
assertRaises
(
BadRequest
,
om
.
__setitem__
,
'1'
,
si2
)
self
.
assertRaises
(
BadRequest
,
om
.
__setitem__
,
'1'
,
si2
)
...
@@ -354,13 +354,13 @@ class ObjectManagerTests(PlacelessSetup, unittest.TestCase):
...
@@ -354,13 +354,13 @@ class ObjectManagerTests(PlacelessSetup, unittest.TestCase):
si2
=
SimpleItem
(
'2'
)
si2
=
SimpleItem
(
'2'
)
om
[
'1'
]
=
si1
om
[
'1'
]
=
si1
om
[
'2'
]
=
si2
om
[
'2'
]
=
si2
self
.
failUnless
(
'1'
in
om
)
self
.
assertTrue
(
'1'
in
om
)
self
.
failUnless
(
'2'
in
om
)
self
.
assertTrue
(
'2'
in
om
)
del
om
[
'1'
]
del
om
[
'1'
]
self
.
failIf
(
'1'
in
om
)
self
.
assertFalse
(
'1'
in
om
)
self
.
failUnless
(
'2'
in
om
)
self
.
assertTrue
(
'2'
in
om
)
om
.
_delObject
(
'2'
)
om
.
_delObject
(
'2'
)
self
.
failIf
(
'2'
in
om
)
self
.
assertFalse
(
'2'
in
om
)
def
test_iterator
(
self
):
def
test_iterator
(
self
):
om
=
self
.
_makeOne
()
om
=
self
.
_makeOne
()
...
@@ -369,11 +369,11 @@ class ObjectManagerTests(PlacelessSetup, unittest.TestCase):
...
@@ -369,11 +369,11 @@ class ObjectManagerTests(PlacelessSetup, unittest.TestCase):
om
[
'1'
]
=
si1
om
[
'1'
]
=
si1
om
[
'2'
]
=
si2
om
[
'2'
]
=
si2
iterator
=
iter
(
om
)
iterator
=
iter
(
om
)
self
.
failUnless
(
hasattr
(
iterator
,
'__iter__'
))
self
.
assertTrue
(
hasattr
(
iterator
,
'__iter__'
))
self
.
failUnless
(
hasattr
(
iterator
,
'next'
))
self
.
assertTrue
(
hasattr
(
iterator
,
'next'
))
result
=
[
i
for
i
in
iterator
]
result
=
[
i
for
i
in
iterator
]
self
.
failUnless
(
'1'
in
result
)
self
.
assertTrue
(
'1'
in
result
)
self
.
failUnless
(
'2'
in
result
)
self
.
assertTrue
(
'2'
in
result
)
def
test_len
(
self
):
def
test_len
(
self
):
om
=
self
.
_makeOne
()
om
=
self
.
_makeOne
()
...
@@ -381,80 +381,80 @@ class ObjectManagerTests(PlacelessSetup, unittest.TestCase):
...
@@ -381,80 +381,80 @@ class ObjectManagerTests(PlacelessSetup, unittest.TestCase):
si2
=
SimpleItem
(
'2'
)
si2
=
SimpleItem
(
'2'
)
om
[
'1'
]
=
si1
om
[
'1'
]
=
si1
om
[
'2'
]
=
si2
om
[
'2'
]
=
si2
self
.
failUnless
(
len
(
om
)
==
2
)
self
.
assertTrue
(
len
(
om
)
==
2
)
def
test_nonzero
(
self
):
def
test_nonzero
(
self
):
om
=
self
.
_makeOne
()
om
=
self
.
_makeOne
()
self
.
failUnless
(
om
)
self
.
assertTrue
(
om
)
def
test_get
(
self
):
def
test_get
(
self
):
om
=
self
.
_makeOne
()
om
=
self
.
_makeOne
()
si1
=
SimpleItem
(
'1'
)
si1
=
SimpleItem
(
'1'
)
self
.
assertRaises
(
BadRequest
,
om
.
__setitem__
,
'get'
,
si1
)
self
.
assertRaises
(
BadRequest
,
om
.
__setitem__
,
'get'
,
si1
)
om
[
'1'
]
=
si1
om
[
'1'
]
=
si1
self
.
failUnless
(
om
.
get
(
'1'
)
==
si1
)
self
.
assertTrue
(
om
.
get
(
'1'
)
==
si1
)
# A contained item overwrites the method
# A contained item overwrites the method
self
.
failUnless
(
hasattr
(
om
.
get
,
'im_func'
))
self
.
assertTrue
(
hasattr
(
om
.
get
,
'im_func'
))
om
.
__dict__
[
'get'
]
=
si1
om
.
__dict__
[
'get'
]
=
si1
self
.
failUnless
(
aq_base
(
om
.
get
)
is
si1
)
self
.
assertTrue
(
aq_base
(
om
.
get
)
is
si1
)
self
.
failUnless
(
aq_base
(
om
[
'get'
])
is
si1
)
self
.
assertTrue
(
aq_base
(
om
[
'get'
])
is
si1
)
# Once the object is gone, the method is back
# Once the object is gone, the method is back
del
om
[
'get'
]
del
om
[
'get'
]
self
.
failUnless
(
hasattr
(
om
.
get
,
'im_func'
))
self
.
assertTrue
(
hasattr
(
om
.
get
,
'im_func'
))
def
test_items
(
self
):
def
test_items
(
self
):
om
=
self
.
_makeOne
()
om
=
self
.
_makeOne
()
si1
=
SimpleItem
(
'1'
)
si1
=
SimpleItem
(
'1'
)
self
.
assertRaises
(
BadRequest
,
om
.
__setitem__
,
'items'
,
si1
)
self
.
assertRaises
(
BadRequest
,
om
.
__setitem__
,
'items'
,
si1
)
om
[
'1'
]
=
si1
om
[
'1'
]
=
si1
self
.
failUnless
((
'1'
,
si1
)
in
om
.
items
())
self
.
assertTrue
((
'1'
,
si1
)
in
om
.
items
())
# A contained item overwrites the method
# A contained item overwrites the method
self
.
failUnless
(
hasattr
(
om
.
items
,
'im_func'
))
self
.
assertTrue
(
hasattr
(
om
.
items
,
'im_func'
))
om
.
__dict__
[
'items'
]
=
si1
om
.
__dict__
[
'items'
]
=
si1
self
.
failUnless
(
aq_base
(
om
.
items
)
is
si1
)
self
.
assertTrue
(
aq_base
(
om
.
items
)
is
si1
)
self
.
failUnless
(
aq_base
(
om
[
'items'
])
is
si1
)
self
.
assertTrue
(
aq_base
(
om
[
'items'
])
is
si1
)
# Once the object is gone, the method is back
# Once the object is gone, the method is back
del
om
[
'items'
]
del
om
[
'items'
]
self
.
failUnless
(
hasattr
(
om
.
items
,
'im_func'
))
self
.
assertTrue
(
hasattr
(
om
.
items
,
'im_func'
))
def
test_keys
(
self
):
def
test_keys
(
self
):
om
=
self
.
_makeOne
()
om
=
self
.
_makeOne
()
si1
=
SimpleItem
(
'1'
)
si1
=
SimpleItem
(
'1'
)
self
.
assertRaises
(
BadRequest
,
om
.
__setitem__
,
'keys'
,
si1
)
self
.
assertRaises
(
BadRequest
,
om
.
__setitem__
,
'keys'
,
si1
)
om
[
'1'
]
=
si1
om
[
'1'
]
=
si1
self
.
failUnless
(
'1'
in
om
.
keys
())
self
.
assertTrue
(
'1'
in
om
.
keys
())
# A contained item overwrites the method
# A contained item overwrites the method
self
.
failUnless
(
hasattr
(
om
.
keys
,
'im_func'
))
self
.
assertTrue
(
hasattr
(
om
.
keys
,
'im_func'
))
om
.
__dict__
[
'keys'
]
=
si1
om
.
__dict__
[
'keys'
]
=
si1
self
.
failUnless
(
aq_base
(
om
.
keys
)
is
si1
)
self
.
assertTrue
(
aq_base
(
om
.
keys
)
is
si1
)
self
.
failUnless
(
aq_base
(
om
[
'keys'
])
is
si1
)
self
.
assertTrue
(
aq_base
(
om
[
'keys'
])
is
si1
)
# Once the object is gone, the method is back
# Once the object is gone, the method is back
del
om
[
'keys'
]
del
om
[
'keys'
]
self
.
failUnless
(
hasattr
(
om
.
keys
,
'im_func'
))
self
.
assertTrue
(
hasattr
(
om
.
keys
,
'im_func'
))
def
test_values
(
self
):
def
test_values
(
self
):
om
=
self
.
_makeOne
()
om
=
self
.
_makeOne
()
si1
=
SimpleItem
(
'1'
)
si1
=
SimpleItem
(
'1'
)
self
.
assertRaises
(
BadRequest
,
om
.
__setitem__
,
'values'
,
si1
)
self
.
assertRaises
(
BadRequest
,
om
.
__setitem__
,
'values'
,
si1
)
om
[
'1'
]
=
si1
om
[
'1'
]
=
si1
self
.
failUnless
(
si1
in
om
.
values
())
self
.
assertTrue
(
si1
in
om
.
values
())
# A contained item overwrites the method
# A contained item overwrites the method
self
.
failUnless
(
hasattr
(
om
.
values
,
'im_func'
))
self
.
assertTrue
(
hasattr
(
om
.
values
,
'im_func'
))
om
.
__dict__
[
'values'
]
=
si1
om
.
__dict__
[
'values'
]
=
si1
self
.
failUnless
(
aq_base
(
om
.
values
)
is
si1
)
self
.
assertTrue
(
aq_base
(
om
.
values
)
is
si1
)
self
.
failUnless
(
aq_base
(
om
[
'values'
])
is
si1
)
self
.
assertTrue
(
aq_base
(
om
[
'values'
])
is
si1
)
# Once the object is gone, the method is back
# Once the object is gone, the method is back
del
om
[
'values'
]
del
om
[
'values'
]
self
.
failUnless
(
hasattr
(
om
.
values
,
'im_func'
))
self
.
assertTrue
(
hasattr
(
om
.
values
,
'im_func'
))
def
test_list_imports
(
self
):
def
test_list_imports
(
self
):
om
=
self
.
_makeOne
()
om
=
self
.
_makeOne
()
# This must work whether we've done "make instance" or not.
# This must work whether we've done "make instance" or not.
# So list_imports() may return an empty list, or whatever's
# So list_imports() may return an empty list, or whatever's
# in skel/import. Tolerate both cases.
# in skel/import. Tolerate both cases.
self
.
failUnless
(
isinstance
(
om
.
list_imports
(),
list
))
self
.
assertTrue
(
isinstance
(
om
.
list_imports
(),
list
))
for
filename
in
om
.
list_imports
():
for
filename
in
om
.
list_imports
():
self
.
failUnless
(
filename
.
endswith
(
'.zexp'
)
or
self
.
assertTrue
(
filename
.
endswith
(
'.zexp'
)
or
filename
.
endswith
(
'.xml'
))
filename
.
endswith
(
'.xml'
))
def
test_suite
():
def
test_suite
():
...
...
src/OFS/tests/testProperties.py
View file @
6220f215
...
@@ -37,20 +37,20 @@ class TestPropertyManager(unittest.TestCase):
...
@@ -37,20 +37,20 @@ class TestPropertyManager(unittest.TestCase):
inst
=
self
.
_makeOne
()
inst
=
self
.
_makeOne
()
inst
.
_setProperty
(
'prop'
,
[
'xxx'
,
'yyy'
],
'lines'
)
inst
.
_setProperty
(
'prop'
,
[
'xxx'
,
'yyy'
],
'lines'
)
self
.
failUnless
(
type
(
inst
.
getProperty
(
'prop'
))
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
getProperty
(
'prop'
))
==
type
(()))
self
.
failUnless
(
type
(
inst
.
prop
)
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
prop
)
==
type
(()))
inst
.
_setPropValue
(
'prop'
,
[
'xxx'
,
'yyy'
])
inst
.
_setPropValue
(
'prop'
,
[
'xxx'
,
'yyy'
])
self
.
failUnless
(
type
(
inst
.
getProperty
(
'prop'
))
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
getProperty
(
'prop'
))
==
type
(()))
self
.
failUnless
(
type
(
inst
.
prop
)
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
prop
)
==
type
(()))
inst
.
_updateProperty
(
'prop'
,
[
'xxx'
,
'yyy'
])
inst
.
_updateProperty
(
'prop'
,
[
'xxx'
,
'yyy'
])
self
.
failUnless
(
type
(
inst
.
getProperty
(
'prop'
))
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
getProperty
(
'prop'
))
==
type
(()))
self
.
failUnless
(
type
(
inst
.
prop
)
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
prop
)
==
type
(()))
inst
.
manage_addProperty
(
'prop2'
,
[
'xxx'
,
'yyy'
],
'lines'
)
inst
.
manage_addProperty
(
'prop2'
,
[
'xxx'
,
'yyy'
],
'lines'
)
self
.
failUnless
(
type
(
inst
.
getProperty
(
'prop2'
))
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
getProperty
(
'prop2'
))
==
type
(()))
self
.
failUnless
(
type
(
inst
.
prop2
)
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
prop2
)
==
type
(()))
def
test_propertyLabel_no_label_falls_back_to_id
(
self
):
def
test_propertyLabel_no_label_falls_back_to_id
(
self
):
class
NoLabel
(
self
.
_getTargetClass
()):
class
NoLabel
(
self
.
_getTargetClass
()):
...
@@ -99,16 +99,16 @@ class TestPropertySheet(unittest.TestCase):
...
@@ -99,16 +99,16 @@ class TestPropertySheet(unittest.TestCase):
inst
=
self
.
_makeOne
(
'foo'
)
inst
=
self
.
_makeOne
(
'foo'
)
inst
.
_setProperty
(
'prop'
,
[
'xxx'
,
'yyy'
],
'lines'
)
inst
.
_setProperty
(
'prop'
,
[
'xxx'
,
'yyy'
],
'lines'
)
self
.
failUnless
(
type
(
inst
.
getProperty
(
'prop'
))
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
getProperty
(
'prop'
))
==
type
(()))
self
.
failUnless
(
type
(
inst
.
prop
)
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
prop
)
==
type
(()))
inst
.
_updateProperty
(
'prop'
,
[
'xxx'
,
'yyy'
])
inst
.
_updateProperty
(
'prop'
,
[
'xxx'
,
'yyy'
])
self
.
failUnless
(
type
(
inst
.
getProperty
(
'prop'
))
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
getProperty
(
'prop'
))
==
type
(()))
self
.
failUnless
(
type
(
inst
.
prop
)
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
prop
)
==
type
(()))
inst
.
manage_addProperty
(
'prop2'
,
[
'xxx'
,
'yyy'
],
'lines'
)
inst
.
manage_addProperty
(
'prop2'
,
[
'xxx'
,
'yyy'
],
'lines'
)
self
.
failUnless
(
type
(
inst
.
getProperty
(
'prop2'
))
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
getProperty
(
'prop2'
))
==
type
(()))
self
.
failUnless
(
type
(
inst
.
prop2
)
==
type
(()))
self
.
assertTrue
(
type
(
inst
.
prop2
)
==
type
(()))
def
test_dav__propstat_nullns
(
self
):
def
test_dav__propstat_nullns
(
self
):
# Tests 15 (propnullns) and 16 (propget) from the props suite
# Tests 15 (propnullns) and 16 (propget) from the props suite
...
...
src/OFS/tests/testRanges.py
View file @
6220f215
...
@@ -121,17 +121,17 @@ class TestRequestRange(unittest.TestCase):
...
@@ -121,17 +121,17 @@ class TestRequestRange(unittest.TestCase):
body
=
self
.
doGET
(
req
,
rsp
)
body
=
self
.
doGET
(
req
,
rsp
)
self
.
failUnless
(
rsp
.
getStatus
()
==
416
,
self
.
assertTrue
(
rsp
.
getStatus
()
==
416
,
'Expected a 416 status, got %s'
%
rsp
.
getStatus
())
'Expected a 416 status, got %s'
%
rsp
.
getStatus
())
expect_content_range
=
'bytes */%d'
%
len
(
self
.
data
)
expect_content_range
=
'bytes */%d'
%
len
(
self
.
data
)
content_range
=
rsp
.
getHeader
(
'content-range'
)
content_range
=
rsp
.
getHeader
(
'content-range'
)
self
.
failIf
(
content_range
is
None
,
'No Content-Range header was set!'
)
self
.
assertFalse
(
content_range
is
None
,
'No Content-Range header was set!'
)
self
.
failUnless
(
content_range
==
expect_content_range
,
self
.
assertTrue
(
content_range
==
expect_content_range
,
'Received incorrect Content-Range header. Expected %s, got %s'
%
(
'Received incorrect Content-Range header. Expected %s, got %s'
%
(
`expect_content_range`
,
`content_range`
))
`expect_content_range`
,
`content_range`
))
self
.
failUnless
(
body
==
''
,
'index_html returned %s'
%
`body`
)
self
.
assertTrue
(
body
==
''
,
'index_html returned %s'
%
`body`
)
def
expectOK
(
self
,
rangeHeader
,
if_range
=
None
):
def
expectOK
(
self
,
rangeHeader
,
if_range
=
None
):
req
=
self
.
app
.
REQUEST
req
=
self
.
app
.
REQUEST
...
@@ -144,7 +144,7 @@ class TestRequestRange(unittest.TestCase):
...
@@ -144,7 +144,7 @@ class TestRequestRange(unittest.TestCase):
body
=
self
.
doGET
(
req
,
rsp
)
body
=
self
.
doGET
(
req
,
rsp
)
self
.
failUnless
(
rsp
.
getStatus
()
==
200
,
self
.
assertTrue
(
rsp
.
getStatus
()
==
200
,
'Expected a 200 status, got %s'
%
rsp
.
getStatus
())
'Expected a 200 status, got %s'
%
rsp
.
getStatus
())
def
expectSingleRange
(
self
,
range
,
start
,
end
,
if_range
=
None
):
def
expectSingleRange
(
self
,
range
,
start
,
end
,
if_range
=
None
):
...
@@ -158,21 +158,21 @@ class TestRequestRange(unittest.TestCase):
...
@@ -158,21 +158,21 @@ class TestRequestRange(unittest.TestCase):
body
=
self
.
doGET
(
req
,
rsp
)
body
=
self
.
doGET
(
req
,
rsp
)
self
.
failUnless
(
rsp
.
getStatus
()
==
206
,
self
.
assertTrue
(
rsp
.
getStatus
()
==
206
,
'Expected a 206 status, got %s'
%
rsp
.
getStatus
())
'Expected a 206 status, got %s'
%
rsp
.
getStatus
())
expect_content_range
=
'bytes %d-%d/%d'
%
(
expect_content_range
=
'bytes %d-%d/%d'
%
(
start
,
end
-
1
,
len
(
self
.
data
))
start
,
end
-
1
,
len
(
self
.
data
))
content_range
=
rsp
.
getHeader
(
'content-range'
)
content_range
=
rsp
.
getHeader
(
'content-range'
)
self
.
failIf
(
content_range
is
None
,
'No Content-Range header was set!'
)
self
.
assertFalse
(
content_range
is
None
,
'No Content-Range header was set!'
)
self
.
failUnless
(
content_range
==
expect_content_range
,
self
.
assertTrue
(
content_range
==
expect_content_range
,
'Received incorrect Content-Range header. Expected %s, got %s'
%
(
'Received incorrect Content-Range header. Expected %s, got %s'
%
(
`expect_content_range`
,
`content_range`
))
`expect_content_range`
,
`content_range`
))
self
.
failIf
(
rsp
.
getHeader
(
'content-length'
)
!=
str
(
len
(
body
)),
self
.
assertFalse
(
rsp
.
getHeader
(
'content-length'
)
!=
str
(
len
(
body
)),
'Incorrect Content-Length is set! Expected %s, got %s.'
%
(
'Incorrect Content-Length is set! Expected %s, got %s.'
%
(
str
(
len
(
body
)),
rsp
.
getHeader
(
'content-length'
)))
str
(
len
(
body
)),
rsp
.
getHeader
(
'content-length'
)))
self
.
failUnless
(
body
==
self
.
data
[
start
:
end
],
self
.
assertTrue
(
body
==
self
.
data
[
start
:
end
],
'Incorrect range returned, expected %s, got %s'
%
(
'Incorrect range returned, expected %s, got %s'
%
(
`self.data[start:end]`
,
`body`
))
`self.data[start:end]`
,
`body`
))
...
@@ -192,18 +192,18 @@ class TestRequestRange(unittest.TestCase):
...
@@ -192,18 +192,18 @@ class TestRequestRange(unittest.TestCase):
body
=
self
.
doGET
(
req
,
rsp
)
body
=
self
.
doGET
(
req
,
rsp
)
self
.
failUnless
(
rsp
.
getStatus
()
==
206
,
self
.
assertTrue
(
rsp
.
getStatus
()
==
206
,
'Expected a 206 status, got %s'
%
rsp
.
getStatus
())
'Expected a 206 status, got %s'
%
rsp
.
getStatus
())
self
.
failIf
(
rsp
.
getHeader
(
'content-range'
),
self
.
assertFalse
(
rsp
.
getHeader
(
'content-range'
),
'The Content-Range header should not be set!'
)
'The Content-Range header should not be set!'
)
ct
=
rsp
.
getHeader
(
'content-type'
).
split
(
';'
)[
0
]
ct
=
rsp
.
getHeader
(
'content-type'
).
split
(
';'
)[
0
]
draftprefix
=
draft
and
'x-'
or
''
draftprefix
=
draft
and
'x-'
or
''
self
.
failIf
(
ct
!=
'multipart/%sbyteranges'
%
draftprefix
,
self
.
assertFalse
(
ct
!=
'multipart/%sbyteranges'
%
draftprefix
,
"Incorrect Content-Type set. Expected 'multipart/%sbyteranges', "
"Incorrect Content-Type set. Expected 'multipart/%sbyteranges', "
"got %s"
%
(
draftprefix
,
ct
))
"got %s"
%
(
draftprefix
,
ct
))
if
rsp
.
getHeader
(
'content-length'
):
if
rsp
.
getHeader
(
'content-length'
):
self
.
failIf
(
rsp
.
getHeader
(
'content-length'
)
!=
str
(
len
(
body
)),
self
.
assertFalse
(
rsp
.
getHeader
(
'content-length'
)
!=
str
(
len
(
body
)),
'Incorrect Content-Length is set! Expected %s, got %s.'
%
(
'Incorrect Content-Length is set! Expected %s, got %s.'
%
(
str
(
len
(
body
)),
rsp
.
getHeader
(
'content-length'
)))
str
(
len
(
body
)),
rsp
.
getHeader
(
'content-length'
)))
...
@@ -224,23 +224,23 @@ class TestRequestRange(unittest.TestCase):
...
@@ -224,23 +224,23 @@ class TestRequestRange(unittest.TestCase):
start
,
end
,
size
=
int
(
start
),
int
(
end
),
int
(
size
)
start
,
end
,
size
=
int
(
start
),
int
(
end
),
int
(
size
)
end
=
end
+
1
end
=
end
+
1
self
.
failIf
(
size
!=
len
(
self
.
data
),
self
.
assertFalse
(
size
!=
len
(
self
.
data
),
'Part Content-Range header reported incorrect length. '
'Part Content-Range header reported incorrect length. '
'Expected %d, got %d.'
%
(
len
(
self
.
data
),
size
))
'Expected %d, got %d.'
%
(
len
(
self
.
data
),
size
))
body
=
part
.
get_payload
()
body
=
part
.
get_payload
()
self
.
failIf
(
len
(
body
)
!=
end
-
start
,
self
.
assertFalse
(
len
(
body
)
!=
end
-
start
,
'Part (%d, %d) is of wrong length, expected %d, got %d.'
%
(
'Part (%d, %d) is of wrong length, expected %d, got %d.'
%
(
start
,
end
,
end
-
start
,
len
(
body
)))
start
,
end
,
end
-
start
,
len
(
body
)))
self
.
failIf
(
body
!=
self
.
data
[
start
:
end
],
self
.
assertFalse
(
body
!=
self
.
data
[
start
:
end
],
'Part (%d, %d) has incorrect data. Expected %s, got %s.'
%
(
'Part (%d, %d) has incorrect data. Expected %s, got %s.'
%
(
start
,
end
,
`self.data[start:end]`
,
`body`
))
start
,
end
,
`self.data[start:end]`
,
`body`
))
add
((
start
,
end
))
add
((
start
,
end
))
# Copmare the ranges used with the expected range sets.
# Copmare the ranges used with the expected range sets.
self
.
failIf
(
returnedRanges
!=
sets
,
self
.
assertFalse
(
returnedRanges
!=
sets
,
'Got unexpected sets, expected %s, got %s'
%
(
'Got unexpected sets, expected %s, got %s'
%
(
sets
,
returnedRanges
))
sets
,
returnedRanges
))
...
...
src/OFS/tests/testSimpleItem.py
View file @
6220f215
...
@@ -40,8 +40,8 @@ class TestItem(unittest.TestCase):
...
@@ -40,8 +40,8 @@ class TestItem(unittest.TestCase):
import
sys
import
sys
self
.
assertEqual
(
sys
.
exc_info
()[
0
],
OverflowError
)
self
.
assertEqual
(
sys
.
exc_info
()[
0
],
OverflowError
)
value
=
sys
.
exc_info
()[
1
]
value
=
sys
.
exc_info
()[
1
]
self
.
failUnless
(
value
.
message
.
startswith
(
"'simple'"
))
self
.
assertTrue
(
value
.
message
.
startswith
(
"'simple'"
))
self
.
failUnless
(
'full details: testing'
in
value
.
message
)
self
.
assertTrue
(
'full details: testing'
in
value
.
message
)
def
test_raise_StandardErrorMessage_TaintedString_errorValue
(
self
):
def
test_raise_StandardErrorMessage_TaintedString_errorValue
(
self
):
from
AccessControl.tainted
import
TaintedString
from
AccessControl.tainted
import
TaintedString
...
@@ -62,7 +62,7 @@ class TestItem(unittest.TestCase):
...
@@ -62,7 +62,7 @@ class TestItem(unittest.TestCase):
import
sys
import
sys
self
.
assertEqual
(
sys
.
exc_info
()[
0
],
OverflowError
)
self
.
assertEqual
(
sys
.
exc_info
()[
0
],
OverflowError
)
value
=
sys
.
exc_info
()[
1
]
value
=
sys
.
exc_info
()[
1
]
self
.
failIf
(
'<'
in
value
.
message
)
self
.
assertFalse
(
'<'
in
value
.
message
)
class
TestItem_w__name__
(
unittest
.
TestCase
):
class
TestItem_w__name__
(
unittest
.
TestCase
):
...
...
src/OFS/tests/testTraverse.py
View file @
6220f215
...
@@ -229,23 +229,23 @@ class TestTraverse( unittest.TestCase ):
...
@@ -229,23 +229,23 @@ class TestTraverse( unittest.TestCase ):
verifyClass
(
ITraversable
,
Traversable
)
verifyClass
(
ITraversable
,
Traversable
)
def
testTraversePath
(
self
):
def
testTraversePath
(
self
):
self
.
failUnless
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
assertTrue
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
failUnless
(
self
.
assertTrue
(
self
.
folder1
.
unrestrictedTraverse
(
(
''
,
'folder1'
,
'file'
)
))
self
.
folder1
.
unrestrictedTraverse
(
(
''
,
'folder1'
,
'file'
)
))
self
.
failUnless
(
self
.
assertTrue
(
self
.
folder1
.
unrestrictedTraverse
(
(
''
,
'folder1'
)
))
self
.
folder1
.
unrestrictedTraverse
(
(
''
,
'folder1'
)
))
def
testTraverseURLNoSlash
(
self
):
def
testTraverseURLNoSlash
(
self
):
self
.
failUnless
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
assertTrue
(
'file'
in
self
.
folder1
.
objectIds
()
)
self
.
failUnless
(
self
.
assertTrue
(
self
.
folder1
.
unrestrictedTraverse
(
'/folder1/file'
))
self
.
folder1
.
unrestrictedTraverse
(
'/folder1/file'
))
self
.
failUnless
(
self
.
assertTrue
(
self
.
folder1
.
unrestrictedTraverse
(
'/folder1'
))
self
.
folder1
.
unrestrictedTraverse
(
'/folder1'
))
def
testTraverseURLSlash
(
self
):
def
testTraverseURLSlash
(
self
):
self
.
failUnless
(
'file'
in
self
.
folder1
.
objectIds
())
self
.
assertTrue
(
'file'
in
self
.
folder1
.
objectIds
())
self
.
failUnless
(
self
.
folder1
.
unrestrictedTraverse
(
'/folder1/file/'
))
self
.
assertTrue
(
self
.
folder1
.
unrestrictedTraverse
(
'/folder1/file/'
))
self
.
failUnless
(
self
.
folder1
.
unrestrictedTraverse
(
'/folder1/'
))
self
.
assertTrue
(
self
.
folder1
.
unrestrictedTraverse
(
'/folder1/'
))
def
testTraverseToNone
(
self
):
def
testTraverseToNone
(
self
):
self
.
failUnlessRaises
(
self
.
failUnlessRaises
(
...
@@ -279,7 +279,7 @@ class TestTraverse( unittest.TestCase ):
...
@@ -279,7 +279,7 @@ class TestTraverse( unittest.TestCase ):
# Verify it's possible to use __bobo_traverse__ to a method.
# Verify it's possible to use __bobo_traverse__ to a method.
self
.
_setupSecurity
()
self
.
_setupSecurity
()
bb
=
self
.
_makeBoboTraversable
()
bb
=
self
.
_makeBoboTraversable
()
self
.
failUnless
(
self
.
assertTrue
(
bb
.
restrictedTraverse
(
'bb_method'
)
is
not
bb
.
bb_method
)
bb
.
restrictedTraverse
(
'bb_method'
)
is
not
bb
.
bb_method
)
def
testBoboTraverseToSimpleAttrValue
(
self
):
def
testBoboTraverseToSimpleAttrValue
(
self
):
...
@@ -296,7 +296,7 @@ class TestTraverse( unittest.TestCase ):
...
@@ -296,7 +296,7 @@ class TestTraverse( unittest.TestCase ):
# is fine, but to test the code branch we sub in the forgiving one
# is fine, but to test the code branch we sub in the forgiving one
self
.
_setupSecurity
(
UnitTestSecurityPolicy
())
self
.
_setupSecurity
(
UnitTestSecurityPolicy
())
bb
=
self
.
_makeBoboTraversable
()
bb
=
self
.
_makeBoboTraversable
()
self
.
failUnless
(
self
.
assertTrue
(
bb
.
restrictedTraverse
(
'manufactured'
)
is
42
)
bb
.
restrictedTraverse
(
'manufactured'
)
is
42
)
def
testBoboTraverseToAcquiredObject
(
self
):
def
testBoboTraverseToAcquiredObject
(
self
):
...
@@ -412,13 +412,13 @@ class TestTraverse( unittest.TestCase ):
...
@@ -412,13 +412,13 @@ class TestTraverse( unittest.TestCase ):
def
testTraverseUp
(
self
):
def
testTraverseUp
(
self
):
# Test that we can traverse upwards
# Test that we can traverse upwards
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
self
.
failUnless
(
self
.
assertTrue
(
aq_base
(
self
.
root
.
folder1
.
file
.
restrictedTraverse
(
'../..'
))
is
aq_base
(
self
.
root
.
folder1
.
file
.
restrictedTraverse
(
'../..'
))
is
aq_base
(
self
.
root
))
aq_base
(
self
.
root
))
def
testTraverseToNameStartingWithPlus
(
self
):
def
testTraverseToNameStartingWithPlus
(
self
):
# Verify it's possible to traverse to a name such as +something
# Verify it's possible to traverse to a name such as +something
self
.
failUnless
(
self
.
assertTrue
(
self
.
folder1
.
unrestrictedTraverse
(
'+something'
)
is
'plus'
)
self
.
folder1
.
unrestrictedTraverse
(
'+something'
)
is
'plus'
)
...
...
src/OFS/tests/test_DTMLDocument.py
View file @
6220f215
...
@@ -24,9 +24,9 @@ class FactoryTests(unittest.TestCase):
...
@@ -24,9 +24,9 @@ class FactoryTests(unittest.TestCase):
dispatcher
=
DummyDispatcher
()
dispatcher
=
DummyDispatcher
()
addDTMLDocument
(
dispatcher
,
'id'
)
addDTMLDocument
(
dispatcher
,
'id'
)
method
=
dispatcher
.
_set
[
'id'
]
method
=
dispatcher
.
_set
[
'id'
]
self
.
failUnless
(
isinstance
(
method
,
DTMLDocument
))
self
.
assertTrue
(
isinstance
(
method
,
DTMLDocument
))
self
.
failIf
(
'standard_html_header'
in
method
.
read
())
self
.
assertFalse
(
'standard_html_header'
in
method
.
read
())
self
.
failIf
(
'standard_html_footer'
in
method
.
read
())
self
.
assertFalse
(
'standard_html_footer'
in
method
.
read
())
class
DummyDispatcher
:
class
DummyDispatcher
:
...
...
src/OFS/tests/test_DTMLMethod.py
View file @
6220f215
...
@@ -33,9 +33,9 @@ class FactoryTests(unittest.TestCase):
...
@@ -33,9 +33,9 @@ class FactoryTests(unittest.TestCase):
dispatcher
=
DummyDispatcher
()
dispatcher
=
DummyDispatcher
()
addDTMLMethod
(
dispatcher
,
'id'
)
addDTMLMethod
(
dispatcher
,
'id'
)
method
=
dispatcher
.
_set
[
'id'
]
method
=
dispatcher
.
_set
[
'id'
]
self
.
failUnless
(
isinstance
(
method
,
DTMLMethod
))
self
.
assertTrue
(
isinstance
(
method
,
DTMLMethod
))
self
.
failIf
(
'standard_html_header'
in
method
.
read
())
self
.
assertFalse
(
'standard_html_header'
in
method
.
read
())
self
.
failIf
(
'standard_html_footer'
in
method
.
read
())
self
.
assertFalse
(
'standard_html_footer'
in
method
.
read
())
class
DummyDispatcher
:
class
DummyDispatcher
:
...
...
src/OFS/tests/test_Uninstalled.py
View file @
6220f215
...
@@ -52,7 +52,7 @@ class TestsOfBroken(unittest.TestCase):
...
@@ -52,7 +52,7 @@ class TestsOfBroken(unittest.TestCase):
klass
=
Broken
(
self
,
None
,
(
'some.python.module'
,
'MyClass'
))
klass
=
Broken
(
self
,
None
,
(
'some.python.module'
,
'MyClass'
))
self
.
failUnless
(
issubclass
(
klass
,
BrokenClass
))
self
.
assertTrue
(
issubclass
(
klass
,
BrokenClass
))
self
.
assertEqual
(
klass
.
__name__
,
'MyClass'
)
self
.
assertEqual
(
klass
.
__name__
,
'MyClass'
)
self
.
assertEqual
(
klass
.
__module__
,
'some.python.module'
)
self
.
assertEqual
(
klass
.
__module__
,
'some.python.module'
)
self
.
assertEqual
(
klass
.
product_name
,
'unknown'
)
self
.
assertEqual
(
klass
.
product_name
,
'unknown'
)
...
@@ -63,7 +63,7 @@ class TestsOfBroken(unittest.TestCase):
...
@@ -63,7 +63,7 @@ class TestsOfBroken(unittest.TestCase):
klass
=
Broken
(
self
,
None
,
(
'Products.MyProduct.MyClass'
,
'MyClass'
))
klass
=
Broken
(
self
,
None
,
(
'Products.MyProduct.MyClass'
,
'MyClass'
))
self
.
failUnless
(
issubclass
(
klass
,
BrokenClass
))
self
.
assertTrue
(
issubclass
(
klass
,
BrokenClass
))
self
.
assertEqual
(
klass
.
__name__
,
'MyClass'
)
self
.
assertEqual
(
klass
.
__name__
,
'MyClass'
)
self
.
assertEqual
(
klass
.
__module__
,
'Products.MyProduct.MyClass'
)
self
.
assertEqual
(
klass
.
__module__
,
'Products.MyProduct.MyClass'
)
self
.
assertEqual
(
klass
.
product_name
,
'MyProduct'
)
self
.
assertEqual
(
klass
.
product_name
,
'MyProduct'
)
...
@@ -75,8 +75,8 @@ class TestsOfBroken(unittest.TestCase):
...
@@ -75,8 +75,8 @@ class TestsOfBroken(unittest.TestCase):
inst
=
Broken
(
self
,
OID
,
(
'Products.MyProduct.MyClass'
,
'MyClass'
))
inst
=
Broken
(
self
,
OID
,
(
'Products.MyProduct.MyClass'
,
'MyClass'
))
self
.
failUnless
(
isinstance
(
inst
,
BrokenClass
))
self
.
assertTrue
(
isinstance
(
inst
,
BrokenClass
))
self
.
failUnless
(
inst
.
_p_jar
is
self
)
self
.
assertTrue
(
inst
.
_p_jar
is
self
)
self
.
assertEqual
(
inst
.
_p_oid
,
OID
)
self
.
assertEqual
(
inst
.
_p_oid
,
OID
)
klass
=
inst
.
__class__
klass
=
inst
.
__class__
...
@@ -130,7 +130,7 @@ class TestsIntegratedBroken(base.TestCase):
...
@@ -130,7 +130,7 @@ class TestsIntegratedBroken(base.TestCase):
# get new connection that will give access to broken object
# get new connection that will give access to broken object
app
=
base
.
app
()
app
=
base
.
app
()
inst
=
aq_base
(
app
.
tr
)
inst
=
aq_base
(
app
.
tr
)
self
.
failUnless
(
isinstance
(
inst
,
BrokenClass
))
self
.
assertTrue
(
isinstance
(
inst
,
BrokenClass
))
state
=
inst
.
__getstate__
()
state
=
inst
.
__getstate__
()
self
.
assertEqual
(
state
,
{
'id'
:
'tr'
})
self
.
assertEqual
(
state
,
{
'id'
:
'tr'
})
...
@@ -139,7 +139,7 @@ class TestsIntegratedBroken(base.TestCase):
...
@@ -139,7 +139,7 @@ class TestsIntegratedBroken(base.TestCase):
transaction
.
commit
()
transaction
.
commit
()
# check that object is not left over
# check that object is not left over
app
=
base
.
app
()
app
=
base
.
app
()
self
.
failIf
(
'tr'
in
app
.
objectIds
())
self
.
assertFalse
(
'tr'
in
app
.
objectIds
())
def
test_suite
():
def
test_suite
():
...
...
src/OFS/tests/test_XMLExportImport.py
View file @
6220f215
...
@@ -63,7 +63,7 @@ class XMLExportImportTests(unittest.TestCase):
...
@@ -63,7 +63,7 @@ class XMLExportImportTests(unittest.TestCase):
stream
.
seek
(
0
)
stream
.
seek
(
0
)
newobj
=
importXML
(
connection
,
stream
)
newobj
=
importXML
(
connection
,
stream
)
self
.
failUnless
(
isinstance
(
newobj
,
DTMLMethod
))
self
.
assertTrue
(
isinstance
(
newobj
,
DTMLMethod
))
self
.
assertEqual
(
newobj
.
read
(),
dm
.
read
())
self
.
assertEqual
(
newobj
.
read
(),
dm
.
read
())
def
test_export_import_as_file_idempotent
(
self
):
def
test_export_import_as_file_idempotent
(
self
):
...
@@ -84,7 +84,7 @@ class XMLExportImportTests(unittest.TestCase):
...
@@ -84,7 +84,7 @@ class XMLExportImportTests(unittest.TestCase):
data
=
exportXML
(
connection
,
oid
,
ostream
)
data
=
exportXML
(
connection
,
oid
,
ostream
)
ostream
.
close
()
ostream
.
close
()
newobj
=
importXML
(
connection
,
path
)
newobj
=
importXML
(
connection
,
path
)
self
.
failUnless
(
isinstance
(
newobj
,
DTMLMethod
))
self
.
assertTrue
(
isinstance
(
newobj
,
DTMLMethod
))
self
.
assertEqual
(
newobj
.
read
(),
dm
.
read
())
self
.
assertEqual
(
newobj
.
read
(),
dm
.
read
())
finally
:
finally
:
# if this operaiton fails with a 'Permission Denied' error,
# if this operaiton fails with a 'Permission Denied' error,
...
...
src/OFS/tests/test_userfolder.py
View file @
6220f215
...
@@ -80,29 +80,29 @@ class UserFolderTests(unittest.TestCase):
...
@@ -80,29 +80,29 @@ class UserFolderTests(unittest.TestCase):
user
=
uf
.
getUser
(
'user1'
)
user
=
uf
.
getUser
(
'user1'
)
app
.
manage_addLocalRoles
(
'user1'
,
[
'Owner'
])
app
.
manage_addLocalRoles
(
'user1'
,
[
'Owner'
])
roles
=
user
.
getRolesInContext
(
app
)
roles
=
user
.
getRolesInContext
(
app
)
self
.
failUnless
(
'role1'
in
roles
)
self
.
assertTrue
(
'role1'
in
roles
)
self
.
failUnless
(
'Owner'
in
roles
)
self
.
assertTrue
(
'Owner'
in
roles
)
def
testHasRole
(
self
):
def
testHasRole
(
self
):
app
=
self
.
_makeApp
()
app
=
self
.
_makeApp
()
uf
=
self
.
_makeOne
(
app
)
uf
=
self
.
_makeOne
(
app
)
user
=
uf
.
getUser
(
'user1'
)
user
=
uf
.
getUser
(
'user1'
)
self
.
failUnless
(
user
.
has_role
(
'role1'
,
app
))
self
.
assertTrue
(
user
.
has_role
(
'role1'
,
app
))
def
testHasLocalRole
(
self
):
def
testHasLocalRole
(
self
):
app
=
self
.
_makeApp
()
app
=
self
.
_makeApp
()
uf
=
self
.
_makeOne
(
app
)
uf
=
self
.
_makeOne
(
app
)
user
=
uf
.
getUser
(
'user1'
)
user
=
uf
.
getUser
(
'user1'
)
app
.
manage_addLocalRoles
(
'user1'
,
[
'Owner'
])
app
.
manage_addLocalRoles
(
'user1'
,
[
'Owner'
])
self
.
failUnless
(
user
.
has_role
(
'Owner'
,
app
))
self
.
assertTrue
(
user
.
has_role
(
'Owner'
,
app
))
def
testHasPermission
(
self
):
def
testHasPermission
(
self
):
app
=
self
.
_makeApp
()
app
=
self
.
_makeApp
()
uf
=
self
.
_makeOne
(
app
)
uf
=
self
.
_makeOne
(
app
)
user
=
uf
.
getUser
(
'user1'
)
user
=
uf
.
getUser
(
'user1'
)
self
.
failUnless
(
user
.
has_permission
(
'View'
,
app
))
self
.
assertTrue
(
user
.
has_permission
(
'View'
,
app
))
app
.
manage_role
(
'role1'
,
[
'Add Folders'
])
app
.
manage_role
(
'role1'
,
[
'Add Folders'
])
self
.
failUnless
(
user
.
has_permission
(
'Add Folders'
,
app
))
self
.
assertTrue
(
user
.
has_permission
(
'Add Folders'
,
app
))
def
testHasLocalRolePermission
(
self
):
def
testHasLocalRolePermission
(
self
):
app
=
self
.
_makeApp
()
app
=
self
.
_makeApp
()
...
@@ -110,13 +110,13 @@ class UserFolderTests(unittest.TestCase):
...
@@ -110,13 +110,13 @@ class UserFolderTests(unittest.TestCase):
user
=
uf
.
getUser
(
'user1'
)
user
=
uf
.
getUser
(
'user1'
)
app
.
manage_role
(
'Owner'
,
[
'Add Folders'
])
app
.
manage_role
(
'Owner'
,
[
'Add Folders'
])
app
.
manage_addLocalRoles
(
'user1'
,
[
'Owner'
])
app
.
manage_addLocalRoles
(
'user1'
,
[
'Owner'
])
self
.
failUnless
(
user
.
has_permission
(
'Add Folders'
,
app
))
self
.
assertTrue
(
user
.
has_permission
(
'Add Folders'
,
app
))
def
testAuthenticate
(
self
):
def
testAuthenticate
(
self
):
app
=
self
.
_makeApp
()
app
=
self
.
_makeApp
()
uf
=
self
.
_makeOne
(
app
)
uf
=
self
.
_makeOne
(
app
)
user
=
uf
.
getUser
(
'user1'
)
user
=
uf
.
getUser
(
'user1'
)
self
.
failUnless
(
user
.
authenticate
(
'secret'
,
app
.
REQUEST
))
self
.
assertTrue
(
user
.
authenticate
(
'secret'
,
app
.
REQUEST
))
def
testValidate
(
self
):
def
testValidate
(
self
):
app
=
self
.
_makeApp
()
app
=
self
.
_makeApp
()
...
...
src/Products/Five/browser/tests/pages_ftest.txt
View file @
6220f215
...
@@ -79,7 +79,7 @@ Unauthorized:
...
@@ -79,7 +79,7 @@ Unauthorized:
... response = self.publish('/test_folder_1_/testoid/%s' % view_name,
... response = self.publish('/test_folder_1_/testoid/%s' % view_name,
... basic='viewer:secret')
... basic='viewer:secret')
... status = response.getStatus()
... status = response.getStatus()
... self.
failUnless
(status == 401, (status, 401, view_name))
... self.
assertTrue
(status == 401, (status, 401, view_name))
Methods of views which were not explicitly declared as allowed should not be
Methods of views which were not explicitly declared as allowed should not be
accessible TTW, even if we have the permission to render the view:
accessible TTW, even if we have the permission to render the view:
...
@@ -101,7 +101,7 @@ except 'View management screens':
...
@@ -101,7 +101,7 @@ except 'View management screens':
... response = self.publish('/test_folder_1_/testoid/%s' % view_name,
... response = self.publish('/test_folder_1_/testoid/%s' % view_name,
... basic='viewer:secret')
... basic='viewer:secret')
... status = response.getStatus()
... status = response.getStatus()
... self.
failUnless
(status == 401, (status, 401, view_name))
... self.
assertTrue
(status == 401, (status, 401, view_name))
If we grant 'View management screens' now, the protected views should
If we grant 'View management screens' now, the protected views should
become viewable:
become viewable:
...
@@ -111,7 +111,7 @@ become viewable:
...
@@ -111,7 +111,7 @@ become viewable:
... response = self.publish('/test_folder_1_/testoid/%s' % view_name,
... response = self.publish('/test_folder_1_/testoid/%s' % view_name,
... basic='viewer:secret')
... basic='viewer:secret')
... status = response.getStatus()
... status = response.getStatus()
... self.
failUnless
(status == 200, (status, 200, view_name))
... self.
assertTrue
(status == 200, (status, 200, view_name))
Managers should always be able to view anything, including proctected
Managers should always be able to view anything, including proctected
stuff:
stuff:
...
@@ -126,7 +126,7 @@ All public views should always be accessible by anyone:
...
@@ -126,7 +126,7 @@ All public views should always be accessible by anyone:
>>> for view_name in public_view_names:
>>> for view_name in public_view_names:
... response = self.publish('/test_folder_1_/testoid/%s' % view_name)
... response = self.publish('/test_folder_1_/testoid/%s' % view_name)
... status = response.getStatus()
... status = response.getStatus()
... self.
failUnless
(status == 200, (status, 200, view_name))
... self.
assertTrue
(status == 200, (status, 200, view_name))
...
...
src/Products/Five/browser/tests/test_metaconfigure.py
View file @
6220f215
...
@@ -33,47 +33,47 @@ class ViewMixinForTemplatesTests(unittest.TestCase):
...
@@ -33,47 +33,47 @@ class ViewMixinForTemplatesTests(unittest.TestCase):
request
=
DummyRequest
()
request
=
DummyRequest
()
view
=
self
.
_makeOne
(
request
=
request
)
view
=
self
.
_makeOne
(
request
=
request
)
index
=
view
.
index
=
DummyTemplate
()
index
=
view
.
index
=
DummyTemplate
()
self
.
failUnless
(
view
.
publishTraverse
(
request
,
'index.html'
)
is
index
)
self
.
assertTrue
(
view
.
publishTraverse
(
request
,
'index.html'
)
is
index
)
def
test___getitem___uses_index_macros
(
self
):
def
test___getitem___uses_index_macros
(
self
):
view
=
self
.
_makeOne
()
view
=
self
.
_makeOne
()
view
.
index
=
index
=
DummyTemplate
()
view
.
index
=
index
=
DummyTemplate
()
index
.
macros
=
{}
index
.
macros
=
{}
index
.
macros
[
'aaa'
]
=
aaa
=
object
()
index
.
macros
[
'aaa'
]
=
aaa
=
object
()
self
.
failUnless
(
view
[
'aaa'
]
is
aaa
)
self
.
assertTrue
(
view
[
'aaa'
]
is
aaa
)
def
test__getitem__gives_shortcut_to_index_macros
(
self
):
def
test__getitem__gives_shortcut_to_index_macros
(
self
):
view
=
self
.
_makeOne
()
view
=
self
.
_makeOne
()
view
.
index
=
index
=
DummyTemplate
()
view
.
index
=
index
=
DummyTemplate
()
index
.
macros
=
{}
index
.
macros
=
{}
self
.
failUnless
(
view
[
'macros'
]
is
index
.
macros
)
self
.
assertTrue
(
view
[
'macros'
]
is
index
.
macros
)
def
test___call___no_args_no_kw
(
self
):
def
test___call___no_args_no_kw
(
self
):
view
=
self
.
_makeOne
()
view
=
self
.
_makeOne
()
view
.
index
=
index
=
DummyTemplate
()
view
.
index
=
index
=
DummyTemplate
()
result
=
view
()
result
=
view
()
self
.
failUnless
(
result
is
index
)
self
.
assertTrue
(
result
is
index
)
self
.
assertEqual
(
index
.
_called_with
,
((),
{}))
self
.
assertEqual
(
index
.
_called_with
,
((),
{}))
def
test___call___w_args_no_kw
(
self
):
def
test___call___w_args_no_kw
(
self
):
view
=
self
.
_makeOne
()
view
=
self
.
_makeOne
()
view
.
index
=
index
=
DummyTemplate
()
view
.
index
=
index
=
DummyTemplate
()
result
=
view
(
'abc'
)
result
=
view
(
'abc'
)
self
.
failUnless
(
result
is
index
)
self
.
assertTrue
(
result
is
index
)
self
.
assertEqual
(
index
.
_called_with
,
((
'abc'
,),
{}))
self
.
assertEqual
(
index
.
_called_with
,
((
'abc'
,),
{}))
def
test___call___no_args_w_kw
(
self
):
def
test___call___no_args_w_kw
(
self
):
view
=
self
.
_makeOne
()
view
=
self
.
_makeOne
()
view
.
index
=
index
=
DummyTemplate
()
view
.
index
=
index
=
DummyTemplate
()
result
=
view
(
foo
=
'bar'
)
result
=
view
(
foo
=
'bar'
)
self
.
failUnless
(
result
is
index
)
self
.
assertTrue
(
result
is
index
)
self
.
assertEqual
(
index
.
_called_with
,
((),
{
'foo'
:
'bar'
}))
self
.
assertEqual
(
index
.
_called_with
,
((),
{
'foo'
:
'bar'
}))
def
test___call___w_args_w_kw
(
self
):
def
test___call___w_args_w_kw
(
self
):
view
=
self
.
_makeOne
()
view
=
self
.
_makeOne
()
view
.
index
=
index
=
DummyTemplate
()
view
.
index
=
index
=
DummyTemplate
()
result
=
view
(
'abc'
,
foo
=
'bar'
)
result
=
view
(
'abc'
,
foo
=
'bar'
)
self
.
failUnless
(
result
is
index
)
self
.
assertTrue
(
result
is
index
)
self
.
assertEqual
(
index
.
_called_with
,
((
'abc'
,),
{
'foo'
:
'bar'
}))
self
.
assertEqual
(
index
.
_called_with
,
((
'abc'
,),
{
'foo'
:
'bar'
}))
...
...
src/Products/Five/browser/tests/test_pagetemplatefile.py
View file @
6220f215
...
@@ -69,17 +69,17 @@ class ViewPageTemplateFileTests(unittest.TestCase):
...
@@ -69,17 +69,17 @@ class ViewPageTemplateFileTests(unittest.TestCase):
view
=
self
.
_makeView
(
context
,
request
)
view
=
self
.
_makeView
(
context
,
request
)
vptf
=
self
.
_makeOne
(
'seagull.pt'
)
vptf
=
self
.
_makeOne
(
'seagull.pt'
)
namespace
=
vptf
.
pt_getContext
(
view
,
request
)
namespace
=
vptf
.
pt_getContext
(
view
,
request
)
self
.
failUnless
(
namespace
[
'context'
]
is
context
)
self
.
assertTrue
(
namespace
[
'context'
]
is
context
)
self
.
failUnless
(
namespace
[
'request'
]
is
request
)
self
.
assertTrue
(
namespace
[
'request'
]
is
request
)
views
=
namespace
[
'views'
]
views
=
namespace
[
'views'
]
self
.
failUnless
(
isinstance
(
views
,
ViewMapper
))
self
.
assertTrue
(
isinstance
(
views
,
ViewMapper
))
self
.
assertEqual
(
views
.
ob
,
context
)
self
.
assertEqual
(
views
.
ob
,
context
)
self
.
assertEqual
(
views
.
request
,
request
)
self
.
assertEqual
(
views
.
request
,
request
)
self
.
failUnless
(
namespace
[
'here'
]
is
context
)
self
.
assertTrue
(
namespace
[
'here'
]
is
context
)
self
.
failUnless
(
namespace
[
'container'
]
is
context
)
self
.
assertTrue
(
namespace
[
'container'
]
is
context
)
self
.
failUnless
(
namespace
[
'root'
]
is
None
)
self
.
assertTrue
(
namespace
[
'root'
]
is
None
)
modules
=
namespace
[
'modules'
]
modules
=
namespace
[
'modules'
]
self
.
failUnless
(
modules
is
SecureModuleImporter
)
self
.
assertTrue
(
modules
is
SecureModuleImporter
)
self
.
assertEqual
(
namespace
[
'traverse_subpath'
],
[])
self
.
assertEqual
(
namespace
[
'traverse_subpath'
],
[])
self
.
assertEqual
(
namespace
[
'user'
].
getId
(),
'a_user'
)
self
.
assertEqual
(
namespace
[
'user'
].
getId
(),
'a_user'
)
...
@@ -95,7 +95,7 @@ class ViewPageTemplateFileTests(unittest.TestCase):
...
@@ -95,7 +95,7 @@ class ViewPageTemplateFileTests(unittest.TestCase):
view
=
self
.
_makeView
(
context
,
request
)
view
=
self
.
_makeView
(
context
,
request
)
vptf
=
self
.
_makeOne
(
'seagull.pt'
)
vptf
=
self
.
_makeOne
(
'seagull.pt'
)
namespace
=
vptf
.
pt_getContext
(
view
,
request
)
namespace
=
vptf
.
pt_getContext
(
view
,
request
)
self
.
failUnless
(
namespace
[
'root'
]
is
root
)
self
.
assertTrue
(
namespace
[
'root'
]
is
root
)
def
test_pt_getContext_w_ignored_kw
(
self
):
def
test_pt_getContext_w_ignored_kw
(
self
):
from
Products.Five.browser.pagetemplatefile
import
ViewMapper
from
Products.Five.browser.pagetemplatefile
import
ViewMapper
...
@@ -107,8 +107,8 @@ class ViewPageTemplateFileTests(unittest.TestCase):
...
@@ -107,8 +107,8 @@ class ViewPageTemplateFileTests(unittest.TestCase):
view
=
self
.
_makeView
(
context
,
request
)
view
=
self
.
_makeView
(
context
,
request
)
vptf
=
self
.
_makeOne
(
'seagull.pt'
)
vptf
=
self
.
_makeOne
(
'seagull.pt'
)
namespace
=
vptf
.
pt_getContext
(
view
,
request
,
foo
=
'bar'
)
namespace
=
vptf
.
pt_getContext
(
view
,
request
,
foo
=
'bar'
)
self
.
failIf
(
'foo'
in
namespace
)
self
.
assertFalse
(
'foo'
in
namespace
)
self
.
failIf
(
'foo'
in
namespace
[
'options'
])
self
.
assertFalse
(
'foo'
in
namespace
[
'options'
])
def
test_pt_getContext_w_args_kw
(
self
):
def
test_pt_getContext_w_args_kw
(
self
):
from
Products.Five.browser.pagetemplatefile
import
ViewMapper
from
Products.Five.browser.pagetemplatefile
import
ViewMapper
...
@@ -166,9 +166,9 @@ class ViewPageTemplateFileTests(unittest.TestCase):
...
@@ -166,9 +166,9 @@ class ViewPageTemplateFileTests(unittest.TestCase):
request
=
DummyRequest
()
request
=
DummyRequest
()
foo
=
Foo
(
context
,
request
)
foo
=
Foo
(
context
,
request
)
bound
=
foo
.
bar
bound
=
foo
.
bar
self
.
failUnless
(
isinstance
(
bound
,
BoundPageTemplate
))
self
.
assertTrue
(
isinstance
(
bound
,
BoundPageTemplate
))
self
.
failUnless
(
bound
.
im_func
is
template
)
self
.
assertTrue
(
bound
.
im_func
is
template
)
self
.
failUnless
(
bound
.
im_self
is
foo
)
self
.
assertTrue
(
bound
.
im_self
is
foo
)
class
ViewMapperTests
(
unittest
.
TestCase
):
class
ViewMapperTests
(
unittest
.
TestCase
):
...
@@ -203,7 +203,7 @@ class ViewMapperTests(unittest.TestCase):
...
@@ -203,7 +203,7 @@ class ViewMapperTests(unittest.TestCase):
return
self
return
self
provideAdapter
(
_adapt
,
(
None
,
None
),
Interface
,
name
=
'test'
)
provideAdapter
(
_adapt
,
(
None
,
None
),
Interface
,
name
=
'test'
)
mapper
=
self
.
_makeOne
()
mapper
=
self
.
_makeOne
()
self
.
failUnless
(
mapper
[
'test'
]
is
self
)
self
.
assertTrue
(
mapper
[
'test'
]
is
self
)
_marker
=
object
()
_marker
=
object
()
...
@@ -224,9 +224,9 @@ class BoundPageTemplateTests(unittest.TestCase):
...
@@ -224,9 +224,9 @@ class BoundPageTemplateTests(unittest.TestCase):
pt
=
DummyTemplate
({
'foo'
:
'bar'
})
pt
=
DummyTemplate
({
'foo'
:
'bar'
})
ob
=
DummyContext
()
ob
=
DummyContext
()
bpt
=
self
.
_makeOne
(
pt
,
ob
)
bpt
=
self
.
_makeOne
(
pt
,
ob
)
self
.
failUnless
(
bpt
.
im_func
is
pt
)
self
.
assertTrue
(
bpt
.
im_func
is
pt
)
self
.
failUnless
(
bpt
.
im_self
is
ob
)
self
.
assertTrue
(
bpt
.
im_self
is
ob
)
self
.
failUnless
(
bpt
.
__parent__
is
ob
)
self
.
assertTrue
(
bpt
.
__parent__
is
ob
)
self
.
assertEqual
(
bpt
.
macros
[
'foo'
],
'bar'
)
self
.
assertEqual
(
bpt
.
macros
[
'foo'
],
'bar'
)
self
.
assertEqual
(
bpt
.
filename
,
'dummy.pt'
)
self
.
assertEqual
(
bpt
.
filename
,
'dummy.pt'
)
...
...
src/Products/PageTemplates/tests/testExpressions.py
View file @
6220f215
...
@@ -95,7 +95,7 @@ class EngineTestsBase(PlacelessSetup):
...
@@ -95,7 +95,7 @@ class EngineTestsBase(PlacelessSetup):
def
test_evaluate_alternative_first_missing
(
self
):
def
test_evaluate_alternative_first_missing
(
self
):
ec
=
self
.
_makeContext
()
ec
=
self
.
_makeContext
()
self
.
failUnless
(
ec
.
evaluate
(
'x | nothing'
)
is
None
)
self
.
assertTrue
(
ec
.
evaluate
(
'x | nothing'
)
is
None
)
def
test_evaluate_dict_key_as_underscore
(
self
):
def
test_evaluate_dict_key_as_underscore
(
self
):
ec
=
self
.
_makeContext
()
ec
=
self
.
_makeContext
()
...
@@ -123,26 +123,26 @@ class EngineTestsBase(PlacelessSetup):
...
@@ -123,26 +123,26 @@ class EngineTestsBase(PlacelessSetup):
def
test_hybrid_with_compound_expression_int_value
(
self
):
def
test_hybrid_with_compound_expression_int_value
(
self
):
ec
=
self
.
_makeContext
()
ec
=
self
.
_makeContext
()
self
.
failUnless
(
ec
.
evaluate
(
'x | not:exists:x'
))
self
.
assertTrue
(
ec
.
evaluate
(
'x | not:exists:x'
))
def
test_access_iterator_from_python_expression
(
self
):
def
test_access_iterator_from_python_expression
(
self
):
ec
=
self
.
_makeContext
()
ec
=
self
.
_makeContext
()
ec
.
beginScope
()
ec
.
beginScope
()
ec
.
setRepeat
(
'loop'
,
"python:[1,2,3]"
)
ec
.
setRepeat
(
'loop'
,
"python:[1,2,3]"
)
self
.
failUnless
(
ec
.
evaluate
(
"python:repeat['loop'].odd()"
))
self
.
assertTrue
(
ec
.
evaluate
(
"python:repeat['loop'].odd()"
))
ec
.
endScope
()
ec
.
endScope
()
def
test_defer_expression_returns_wrapper
(
self
):
def
test_defer_expression_returns_wrapper
(
self
):
from
zope.tales.expressions
import
DeferWrapper
from
zope.tales.expressions
import
DeferWrapper
ec
=
self
.
_makeContext
()
ec
=
self
.
_makeContext
()
defer
=
ec
.
evaluate
(
'defer: b'
)
defer
=
ec
.
evaluate
(
'defer: b'
)
self
.
failUnless
(
isinstance
(
defer
,
DeferWrapper
))
self
.
assertTrue
(
isinstance
(
defer
,
DeferWrapper
))
def
test_lazy_expression_returns_wrapper
(
self
):
def
test_lazy_expression_returns_wrapper
(
self
):
from
zope.tales.expressions
import
LazyWrapper
from
zope.tales.expressions
import
LazyWrapper
ec
=
self
.
_makeContext
()
ec
=
self
.
_makeContext
()
lazy
=
ec
.
evaluate
(
'lazy: b'
)
lazy
=
ec
.
evaluate
(
'lazy: b'
)
self
.
failUnless
(
isinstance
(
lazy
,
LazyWrapper
))
self
.
assertTrue
(
isinstance
(
lazy
,
LazyWrapper
))
def
test_empty_path_expression_explicit
(
self
):
def
test_empty_path_expression_explicit
(
self
):
ec
=
self
.
_makeContext
()
ec
=
self
.
_makeContext
()
...
@@ -168,7 +168,7 @@ class EngineTestsBase(PlacelessSetup):
...
@@ -168,7 +168,7 @@ class EngineTestsBase(PlacelessSetup):
# only bothers compiling true strings, not unicode strings
# only bothers compiling true strings, not unicode strings
result
=
ec
.
evaluate
(
eng
.
compile
(
u'string:x'
))
result
=
ec
.
evaluate
(
eng
.
compile
(
u'string:x'
))
self
.
assertEqual
(
result
,
u'x'
)
self
.
assertEqual
(
result
,
u'x'
)
self
.
failUnless
(
isinstance
(
result
,
unicode
))
self
.
assertTrue
(
isinstance
(
result
,
unicode
))
def
test_mixed
(
self
):
def
test_mixed
(
self
):
# 8-bit strings in unicode string expressions cause UnicodeDecodeErrors
# 8-bit strings in unicode string expressions cause UnicodeDecodeErrors
...
@@ -289,7 +289,7 @@ class ZopeContextTests(unittest.TestCase):
...
@@ -289,7 +289,7 @@ class ZopeContextTests(unittest.TestCase):
# See: https://bugs.launchpad.net/zope2/+bug/174705
# See: https://bugs.launchpad.net/zope2/+bug/174705
context
=
self
.
_makeOne
()
context
=
self
.
_makeOne
()
info
=
context
.
createErrorInfo
(
AttributeError
(
'nonesuch'
),
(
12
,
3
))
info
=
context
.
createErrorInfo
(
AttributeError
(
'nonesuch'
),
(
12
,
3
))
self
.
failUnless
(
info
.
type
is
AttributeError
)
self
.
assertTrue
(
info
.
type
is
AttributeError
)
self
.
assertEqual
(
info
.
__allow_access_to_unprotected_subobjects__
,
1
)
self
.
assertEqual
(
info
.
__allow_access_to_unprotected_subobjects__
,
1
)
def
test_suite
():
def
test_suite
():
...
...
src/Products/PageTemplates/tests/testZRPythonExpr.py
View file @
6220f215
...
@@ -13,14 +13,14 @@ class MiscTests(unittest.TestCase):
...
@@ -13,14 +13,14 @@ class MiscTests(unittest.TestCase):
request
=
{
'request'
:
1
}
request
=
{
'request'
:
1
}
names
=
{
'context'
:
context
,
'here'
:
here
,
'request'
:
request
}
names
=
{
'context'
:
context
,
'here'
:
here
,
'request'
:
request
}
result
=
call_with_ns
(
lambda
td
:
td
.
this
,
names
)
result
=
call_with_ns
(
lambda
td
:
td
.
this
,
names
)
self
.
failUnless
(
result
is
context
,
result
)
self
.
assertTrue
(
result
is
context
,
result
)
def
test_call_with_ns_no_context_or_here
(
self
):
def
test_call_with_ns_no_context_or_here
(
self
):
from
Products.PageTemplates.ZRPythonExpr
import
call_with_ns
from
Products.PageTemplates.ZRPythonExpr
import
call_with_ns
request
=
{
'request'
:
1
}
request
=
{
'request'
:
1
}
names
=
{
'request'
:
request
}
names
=
{
'request'
:
request
}
result
=
call_with_ns
(
lambda
td
:
td
.
this
,
names
)
result
=
call_with_ns
(
lambda
td
:
td
.
this
,
names
)
self
.
failUnless
(
result
is
None
,
result
)
self
.
assertTrue
(
result
is
None
,
result
)
def
test_call_with_ns_no_request
(
self
):
def
test_call_with_ns_no_request
(
self
):
from
Products.PageTemplates.ZRPythonExpr
import
call_with_ns
from
Products.PageTemplates.ZRPythonExpr
import
call_with_ns
...
...
src/Products/PageTemplates/tests/testZopePageTemplate.py
View file @
6220f215
...
@@ -135,7 +135,7 @@ class ZPTUnicodeEncodingConflictResolution(ZopeTestCase):
...
@@ -135,7 +135,7 @@ class ZPTUnicodeEncodingConflictResolution(ZopeTestCase):
self
.
app
.
REQUEST
.
set
(
'HTTP_ACCEPT_CHARSET'
,
'ISO-8859-15,utf-8'
)
self
.
app
.
REQUEST
.
set
(
'HTTP_ACCEPT_CHARSET'
,
'ISO-8859-15,utf-8'
)
self
.
app
.
REQUEST
.
set
(
'data'
,
''
)
self
.
app
.
REQUEST
.
set
(
'data'
,
''
)
result
=
zpt
.
pt_render
()
result
=
zpt
.
pt_render
()
self
.
failUnless
(
result
.
startswith
(
unicode
(
'<div></div>'
,
self
.
assertTrue
(
result
.
startswith
(
unicode
(
'<div></div>'
,
'iso-8859-15'
)))
'iso-8859-15'
)))
def
testUTF8
(
self
):
def
testUTF8
(
self
):
...
@@ -148,7 +148,7 @@ class ZPTUnicodeEncodingConflictResolution(ZopeTestCase):
...
@@ -148,7 +148,7 @@ class ZPTUnicodeEncodingConflictResolution(ZopeTestCase):
self
.
app
.
REQUEST
.
set
(
'data'
,
self
.
app
.
REQUEST
.
set
(
'data'
,
unicode
(
''
,
'iso-8859-15'
).
encode
(
'utf-8'
))
unicode
(
''
,
'iso-8859-15'
).
encode
(
'utf-8'
))
result
=
zpt
.
pt_render
()
result
=
zpt
.
pt_render
()
self
.
failUnless
(
result
.
startswith
(
unicode
(
'<div></div>'
,
self
.
assertTrue
(
result
.
startswith
(
unicode
(
'<div></div>'
,
'iso-8859-15'
)))
'iso-8859-15'
)))
def
testUTF8WrongPreferredCharset
(
self
):
def
testUTF8WrongPreferredCharset
(
self
):
...
@@ -161,7 +161,7 @@ class ZPTUnicodeEncodingConflictResolution(ZopeTestCase):
...
@@ -161,7 +161,7 @@ class ZPTUnicodeEncodingConflictResolution(ZopeTestCase):
self
.
app
.
REQUEST
.
set
(
'data'
,
self
.
app
.
REQUEST
.
set
(
'data'
,
unicode
(
''
,
'iso-8859-15'
).
encode
(
'utf-8'
))
unicode
(
''
,
'iso-8859-15'
).
encode
(
'utf-8'
))
result
=
zpt
.
pt_render
()
result
=
zpt
.
pt_render
()
self
.
failIf
(
result
.
startswith
(
unicode
(
'<div></div>'
,
self
.
assertFalse
(
result
.
startswith
(
unicode
(
'<div></div>'
,
'iso-8859-15'
)))
'iso-8859-15'
)))
def
testStructureWithAccentedChars
(
self
):
def
testStructureWithAccentedChars
(
self
):
...
@@ -174,7 +174,7 @@ class ZPTUnicodeEncodingConflictResolution(ZopeTestCase):
...
@@ -174,7 +174,7 @@ class ZPTUnicodeEncodingConflictResolution(ZopeTestCase):
self
.
app
.
REQUEST
.
set
(
'data'
,
unicode
(
''
,
self
.
app
.
REQUEST
.
set
(
'data'
,
unicode
(
''
,
'iso-8859-15'
).
encode
(
'utf-8'
))
'iso-8859-15'
).
encode
(
'utf-8'
))
result
=
zpt
.
pt_render
()
result
=
zpt
.
pt_render
()
self
.
failUnless
(
result
.
startswith
(
unicode
(
'<div></div>'
,
self
.
assertTrue
(
result
.
startswith
(
unicode
(
'<div></div>'
,
'iso-8859-15'
)))
'iso-8859-15'
)))
def
testBug151020
(
self
):
def
testBug151020
(
self
):
...
@@ -188,7 +188,7 @@ class ZPTUnicodeEncodingConflictResolution(ZopeTestCase):
...
@@ -188,7 +188,7 @@ class ZPTUnicodeEncodingConflictResolution(ZopeTestCase):
self
.
app
.
REQUEST
.
set
(
'data'
,
self
.
app
.
REQUEST
.
set
(
'data'
,
unicode
(
''
,
'iso-8859-15'
).
encode
(
'utf-8'
))
unicode
(
''
,
'iso-8859-15'
).
encode
(
'utf-8'
))
result
=
zpt
.
pt_render
()
result
=
zpt
.
pt_render
()
self
.
failUnless
(
result
.
startswith
(
unicode
(
'<div></div>'
,
self
.
assertTrue
(
result
.
startswith
(
unicode
(
'<div></div>'
,
'iso-8859-15'
)))
'iso-8859-15'
)))
def
test_bug_198274
(
self
):
def
test_bug_198274
(
self
):
...
@@ -268,7 +268,7 @@ class ZopePageTemplateFileTests(ZopeTestCase):
...
@@ -268,7 +268,7 @@ class ZopePageTemplateFileTests(ZopeTestCase):
zpt
=
self
.
app
[
'test'
]
zpt
=
self
.
app
[
'test'
]
result
=
zpt
.
pt_render
()
result
=
zpt
.
pt_render
()
# use startswith() because the renderer appends a trailing \n
# use startswith() because the renderer appends a trailing \n
self
.
failUnless
(
result
.
encode
(
'iso-8859-15'
self
.
assertTrue
(
result
.
encode
(
'iso-8859-15'
).
startswith
(
iso885915_str
))
).
startswith
(
iso885915_str
))
self
.
assertEqual
(
zpt
.
output_encoding
,
'iso-8859-15'
)
self
.
assertEqual
(
zpt
.
output_encoding
,
'iso-8859-15'
)
...
...
src/Products/PageTemplates/tests/test_ptfile.py
View file @
6220f215
...
@@ -206,7 +206,7 @@ class LazyLoadingTestCase(unittest.TestCase):
...
@@ -206,7 +206,7 @@ class LazyLoadingTestCase(unittest.TestCase):
print
>>
f
,
'Lazyness'
print
>>
f
,
'Lazyness'
f
.
close
()
f
.
close
()
pt
=
PageTemplateFile
(
self
.
TEMPFILENAME
)
pt
=
PageTemplateFile
(
self
.
TEMPFILENAME
)
self
.
failUnless
(
not
pt
.
_text
and
not
pt
.
_v_program
)
self
.
assertTrue
(
not
pt
.
_text
and
not
pt
.
_v_program
)
def
test_suite
():
def
test_suite
():
...
...
src/Products/PluginIndexes/DateIndex/tests/test_DateIndex.py
View file @
6220f215
...
@@ -140,7 +140,7 @@ class DI_Tests(unittest.TestCase):
...
@@ -140,7 +140,7 @@ class DI_Tests(unittest.TestCase):
self
.
failUnlessEqual
(
len
(
result
),
len
(
expectedValues
),
self
.
failUnlessEqual
(
len
(
result
),
len
(
expectedValues
),
'%s | %s'
%
(
result
,
expectedValues
))
'%s | %s'
%
(
result
,
expectedValues
))
for
k
,
v
in
expectedValues
:
for
k
,
v
in
expectedValues
:
self
.
failUnless
(
k
in
result
)
self
.
assertTrue
(
k
in
result
)
def
_convert
(
self
,
dt
):
def
_convert
(
self
,
dt
):
from
time
import
gmtime
from
time
import
gmtime
...
@@ -178,16 +178,16 @@ class DI_Tests(unittest.TestCase):
...
@@ -178,16 +178,16 @@ class DI_Tests(unittest.TestCase):
self
.
failUnlessEqual
(
len
(
index
),
0
)
self
.
failUnlessEqual
(
len
(
index
),
0
)
self
.
failUnlessEqual
(
len
(
index
.
referencedObjects
()),
0
)
self
.
failUnlessEqual
(
len
(
index
.
referencedObjects
()),
0
)
self
.
failUnless
(
index
.
getEntryForObject
(
1234
)
is
None
)
self
.
assertTrue
(
index
.
getEntryForObject
(
1234
)
is
None
)
marker
=
[]
marker
=
[]
self
.
failUnless
(
index
.
getEntryForObject
(
1234
,
marker
)
is
marker
)
self
.
assertTrue
(
index
.
getEntryForObject
(
1234
,
marker
)
is
marker
)
index
.
unindex_object
(
1234
)
# shouldn't throw
index
.
unindex_object
(
1234
)
# shouldn't throw
self
.
failUnless
(
index
.
hasUniqueValuesFor
(
'date'
))
self
.
assertTrue
(
index
.
hasUniqueValuesFor
(
'date'
))
self
.
failIf
(
index
.
hasUniqueValuesFor
(
'foo'
))
self
.
assertFalse
(
index
.
hasUniqueValuesFor
(
'foo'
))
self
.
failUnlessEqual
(
len
(
index
.
uniqueValues
(
'date'
)),
0
)
self
.
failUnlessEqual
(
len
(
index
.
uniqueValues
(
'date'
)),
0
)
self
.
failUnless
(
index
.
_apply_index
({
'zed'
:
12345
})
is
None
)
self
.
assertTrue
(
index
.
_apply_index
({
'zed'
:
12345
})
is
None
)
self
.
_checkApply
(
index
,
self
.
_checkApply
(
index
,
{
'date'
:
DateTime
(
0
)},
[])
{
'date'
:
DateTime
(
0
)},
[])
...
@@ -215,9 +215,9 @@ class DI_Tests(unittest.TestCase):
...
@@ -215,9 +215,9 @@ class DI_Tests(unittest.TestCase):
self
.
failUnlessEqual
(
len
(
index
.
referencedObjects
()),
len
(
values
)
-
1
)
self
.
failUnlessEqual
(
len
(
index
.
referencedObjects
()),
len
(
values
)
-
1
)
# One empty
# One empty
self
.
failUnless
(
index
.
getEntryForObject
(
1234
)
is
None
)
self
.
assertTrue
(
index
.
getEntryForObject
(
1234
)
is
None
)
marker
=
[]
marker
=
[]
self
.
failUnless
(
index
.
getEntryForObject
(
1234
,
marker
)
is
marker
)
self
.
assertTrue
(
index
.
getEntryForObject
(
1234
,
marker
)
is
marker
)
index
.
unindex_object
(
1234
)
# shouldn't throw
index
.
unindex_object
(
1234
)
# shouldn't throw
for
k
,
v
in
values
:
for
k
,
v
in
values
:
...
@@ -226,7 +226,7 @@ class DI_Tests(unittest.TestCase):
...
@@ -226,7 +226,7 @@ class DI_Tests(unittest.TestCase):
self
.
_convert
(
v
.
date
()))
self
.
_convert
(
v
.
date
()))
self
.
failUnlessEqual
(
len
(
index
.
uniqueValues
(
'date'
)),
len
(
values
)
-
2
)
self
.
failUnlessEqual
(
len
(
index
.
uniqueValues
(
'date'
)),
len
(
values
)
-
2
)
self
.
failUnless
(
index
.
_apply_index
({
'bar'
:
123
})
is
None
)
self
.
assertTrue
(
index
.
_apply_index
({
'bar'
:
123
})
is
None
)
self
.
_checkApply
(
index
,
self
.
_checkApply
(
index
,
{
'date'
:
DateTime
(
0
)},
values
[
1
:
2
])
{
'date'
:
DateTime
(
0
)},
values
[
1
:
2
])
...
@@ -273,7 +273,7 @@ class DI_Tests(unittest.TestCase):
...
@@ -273,7 +273,7 @@ class DI_Tests(unittest.TestCase):
self
.
_checkApply
(
index
,
self
.
_checkApply
(
index
,
{
'date'
:
1072742900
},
[
values
[
7
]])
{
'date'
:
1072742900
},
[
values
[
7
]])
index
.
index_object
(
7
,
None
)
index
.
index_object
(
7
,
None
)
self
.
failIf
(
7
in
index
.
documentToKeyMap
().
keys
())
self
.
assertFalse
(
7
in
index
.
documentToKeyMap
().
keys
())
def
test_suite
():
def
test_suite
():
...
...
src/Products/PluginIndexes/DateRangeIndex/tests/test_DateRangeIndex.py
View file @
6220f215
...
@@ -97,17 +97,17 @@ class DRI_Tests( unittest.TestCase ):
...
@@ -97,17 +97,17 @@ class DRI_Tests( unittest.TestCase ):
empty
=
self
.
_makeOne
(
'empty'
)
empty
=
self
.
_makeOne
(
'empty'
)
self
.
failUnless
(
empty
.
getEntryForObject
(
1234
)
is
None
)
self
.
assertTrue
(
empty
.
getEntryForObject
(
1234
)
is
None
)
empty
.
unindex_object
(
1234
)
# shouldn't throw
empty
.
unindex_object
(
1234
)
# shouldn't throw
self
.
failIf
(
empty
.
uniqueValues
(
'foo'
))
self
.
assertFalse
(
empty
.
uniqueValues
(
'foo'
))
self
.
failIf
(
empty
.
uniqueValues
(
'foo'
,
1
))
self
.
assertFalse
(
empty
.
uniqueValues
(
'foo'
,
1
))
self
.
failUnless
(
empty
.
_apply_index
(
{
'zed'
:
12345
}
)
is
None
)
self
.
assertTrue
(
empty
.
_apply_index
(
{
'zed'
:
12345
}
)
is
None
)
result
,
used
=
empty
.
_apply_index
(
{
'empty'
:
12345
}
)
result
,
used
=
empty
.
_apply_index
(
{
'empty'
:
12345
}
)
self
.
failIf
(
result
)
self
.
assertFalse
(
result
)
self
.
assertEqual
(
used
,
(
None
,
None
))
self
.
assertEqual
(
used
,
(
None
,
None
))
def
test_retrieval
(
self
):
def
test_retrieval
(
self
):
...
...
src/Products/PluginIndexes/KeywordIndex/tests/testKeywordIndex.py
View file @
6220f215
...
@@ -243,8 +243,8 @@ class TestKeywordIndex( unittest.TestCase ):
...
@@ -243,8 +243,8 @@ class TestKeywordIndex( unittest.TestCase ):
def
test_noindexing_when_noattribute
(
self
):
def
test_noindexing_when_noattribute
(
self
):
to_index
=
Dummy
([
'hello'
])
to_index
=
Dummy
([
'hello'
])
self
.
_index
.
_index_object
(
10
,
to_index
,
attr
=
'UNKNOWN'
)
self
.
_index
.
_index_object
(
10
,
to_index
,
attr
=
'UNKNOWN'
)
self
.
failIf
(
self
.
_index
.
_unindex
.
get
(
10
))
self
.
assertFalse
(
self
.
_index
.
_unindex
.
get
(
10
))
self
.
failIf
(
self
.
_index
.
getEntryForObject
(
10
))
self
.
assertFalse
(
self
.
_index
.
getEntryForObject
(
10
))
def
test_noindexing_when_raising_attribute
(
self
):
def
test_noindexing_when_raising_attribute
(
self
):
class
FauxObject
:
class
FauxObject
:
...
@@ -252,18 +252,18 @@ class TestKeywordIndex( unittest.TestCase ):
...
@@ -252,18 +252,18 @@ class TestKeywordIndex( unittest.TestCase ):
raise
AttributeError
raise
AttributeError
to_index
=
FauxObject
()
to_index
=
FauxObject
()
self
.
_index
.
_index_object
(
10
,
to_index
,
attr
=
'foo'
)
self
.
_index
.
_index_object
(
10
,
to_index
,
attr
=
'foo'
)
self
.
failIf
(
self
.
_index
.
_unindex
.
get
(
10
))
self
.
assertFalse
(
self
.
_index
.
_unindex
.
get
(
10
))
self
.
failIf
(
self
.
_index
.
getEntryForObject
(
10
))
self
.
assertFalse
(
self
.
_index
.
getEntryForObject
(
10
))
def
test_value_removes
(
self
):
def
test_value_removes
(
self
):
to_index
=
Dummy
([
'hello'
])
to_index
=
Dummy
([
'hello'
])
self
.
_index
.
_index_object
(
10
,
to_index
,
attr
=
'foo'
)
self
.
_index
.
_index_object
(
10
,
to_index
,
attr
=
'foo'
)
self
.
failUnless
(
self
.
_index
.
_unindex
.
get
(
10
))
self
.
assertTrue
(
self
.
_index
.
_unindex
.
get
(
10
))
to_index
=
Dummy
(
''
)
to_index
=
Dummy
(
''
)
self
.
_index
.
_index_object
(
10
,
to_index
,
attr
=
'foo'
)
self
.
_index
.
_index_object
(
10
,
to_index
,
attr
=
'foo'
)
self
.
failIf
(
self
.
_index
.
_unindex
.
get
(
10
))
self
.
assertFalse
(
self
.
_index
.
_unindex
.
get
(
10
))
def
test_suite
():
def
test_suite
():
...
...
src/Products/PluginIndexes/PathIndex/tests/testPathIndex.py
View file @
6220f215
...
@@ -121,7 +121,7 @@ class PathIndexTests(unittest.TestCase):
...
@@ -121,7 +121,7 @@ class PathIndexTests(unittest.TestCase):
def
test_getEntryForObject_miss_w_default
(
self
):
def
test_getEntryForObject_miss_w_default
(
self
):
index
=
self
.
_makeOne
()
index
=
self
.
_makeOne
()
default
=
object
()
default
=
object
()
self
.
failUnless
(
index
.
getEntryForObject
(
1234
,
default
)
is
default
)
self
.
assertTrue
(
index
.
getEntryForObject
(
1234
,
default
)
is
default
)
def
test_getEntryForObject_hit
(
self
):
def
test_getEntryForObject_hit
(
self
):
index
=
self
.
_makeOne
()
index
=
self
.
_makeOne
()
...
@@ -402,11 +402,11 @@ class PathIndexTests(unittest.TestCase):
...
@@ -402,11 +402,11 @@ class PathIndexTests(unittest.TestCase):
def
test_hasUniqueValuesFor_miss
(
self
):
def
test_hasUniqueValuesFor_miss
(
self
):
index
=
self
.
_makeOne
()
index
=
self
.
_makeOne
()
self
.
failIf
(
index
.
hasUniqueValuesFor
(
'miss'
))
self
.
assertFalse
(
index
.
hasUniqueValuesFor
(
'miss'
))
def
test_hasUniqueValuesFor_hit
(
self
):
def
test_hasUniqueValuesFor_hit
(
self
):
index
=
self
.
_makeOne
()
index
=
self
.
_makeOne
()
self
.
failUnless
(
index
.
hasUniqueValuesFor
(
'path'
))
self
.
assertTrue
(
index
.
hasUniqueValuesFor
(
'path'
))
def
test_uniqueValues_empty
(
self
):
def
test_uniqueValues_empty
(
self
):
index
=
self
.
_makeOne
()
index
=
self
.
_makeOne
()
...
...
src/Products/Sessions/tests/testBrowserIdManager.py
View file @
6220f215
This diff is collapsed.
Click to expand it.
src/Products/Sessions/tests/testSessionDataManager.py
View file @
6220f215
...
@@ -111,28 +111,28 @@ class TestSessionManager(unittest.TestCase):
...
@@ -111,28 +111,28 @@ class TestSessionManager(unittest.TestCase):
del
self
.
app
del
self
.
app
def
testHasId
(
self
):
def
testHasId
(
self
):
self
.
failUnless
(
self
.
app
.
session_data_manager
.
id
==
\
self
.
assertTrue
(
self
.
app
.
session_data_manager
.
id
==
\
sdm_name
)
sdm_name
)
def
testHasTitle
(
self
):
def
testHasTitle
(
self
):
self
.
failUnless
(
self
.
app
.
session_data_manager
.
title
\
self
.
assertTrue
(
self
.
app
.
session_data_manager
.
title
\
==
'Session Data Manager'
)
==
'Session Data Manager'
)
def
testGetSessionDataNoCreate
(
self
):
def
testGetSessionDataNoCreate
(
self
):
sd
=
self
.
app
.
session_data_manager
.
getSessionData
(
0
)
sd
=
self
.
app
.
session_data_manager
.
getSessionData
(
0
)
self
.
failUnless
(
sd
is
None
)
self
.
assertTrue
(
sd
is
None
)
def
testGetSessionDataCreate
(
self
):
def
testGetSessionDataCreate
(
self
):
from
Products.Transience.Transience
import
TransientObject
from
Products.Transience.Transience
import
TransientObject
sd
=
self
.
app
.
session_data_manager
.
getSessionData
(
1
)
sd
=
self
.
app
.
session_data_manager
.
getSessionData
(
1
)
self
.
failUnless
(
sd
.
__class__
is
TransientObject
)
self
.
assertTrue
(
sd
.
__class__
is
TransientObject
)
def
testHasSessionData
(
self
):
def
testHasSessionData
(
self
):
sd
=
self
.
app
.
session_data_manager
.
getSessionData
()
sd
=
self
.
app
.
session_data_manager
.
getSessionData
()
self
.
failUnless
(
self
.
app
.
session_data_manager
.
hasSessionData
())
self
.
assertTrue
(
self
.
app
.
session_data_manager
.
hasSessionData
())
def
testNotHasSessionData
(
self
):
def
testNotHasSessionData
(
self
):
self
.
failUnless
(
not
self
.
app
.
session_data_manager
.
hasSessionData
())
self
.
assertTrue
(
not
self
.
app
.
session_data_manager
.
hasSessionData
())
def
testSessionDataWrappedInSDMandTOC
(
self
):
def
testSessionDataWrappedInSDMandTOC
(
self
):
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
...
@@ -140,28 +140,28 @@ class TestSessionManager(unittest.TestCase):
...
@@ -140,28 +140,28 @@ class TestSessionManager(unittest.TestCase):
sdm
=
aq_base
(
getattr
(
self
.
app
,
sdm_name
))
sdm
=
aq_base
(
getattr
(
self
.
app
,
sdm_name
))
toc
=
aq_base
(
getattr
(
self
.
app
.
temp_folder
,
toc_name
))
toc
=
aq_base
(
getattr
(
self
.
app
.
temp_folder
,
toc_name
))
self
.
failUnless
(
aq_base
(
sd
.
aq_parent
)
is
sdm
)
self
.
assertTrue
(
aq_base
(
sd
.
aq_parent
)
is
sdm
)
self
.
failUnless
(
aq_base
(
sd
.
aq_parent
.
aq_parent
)
is
toc
)
self
.
assertTrue
(
aq_base
(
sd
.
aq_parent
.
aq_parent
)
is
toc
)
def
testNewSessionDataObjectIsValid
(
self
):
def
testNewSessionDataObjectIsValid
(
self
):
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
from
Products.Transience.Transience
import
TransientObject
from
Products.Transience.Transience
import
TransientObject
sdType
=
type
(
TransientObject
(
1
))
sdType
=
type
(
TransientObject
(
1
))
sd
=
self
.
app
.
session_data_manager
.
getSessionData
()
sd
=
self
.
app
.
session_data_manager
.
getSessionData
()
self
.
failUnless
(
type
(
aq_base
(
sd
))
is
sdType
)
self
.
assertTrue
(
type
(
aq_base
(
sd
))
is
sdType
)
self
.
failUnless
(
not
hasattr
(
sd
,
'_invalid'
))
self
.
assertTrue
(
not
hasattr
(
sd
,
'_invalid'
))
def
testBrowserIdIsSet
(
self
):
def
testBrowserIdIsSet
(
self
):
sd
=
self
.
app
.
session_data_manager
.
getSessionData
()
sd
=
self
.
app
.
session_data_manager
.
getSessionData
()
mgr
=
getattr
(
self
.
app
,
idmgr_name
)
mgr
=
getattr
(
self
.
app
,
idmgr_name
)
self
.
failUnless
(
mgr
.
hasBrowserId
())
self
.
assertTrue
(
mgr
.
hasBrowserId
())
def
testGetSessionDataByKey
(
self
):
def
testGetSessionDataByKey
(
self
):
sd
=
self
.
app
.
session_data_manager
.
getSessionData
()
sd
=
self
.
app
.
session_data_manager
.
getSessionData
()
mgr
=
getattr
(
self
.
app
,
idmgr_name
)
mgr
=
getattr
(
self
.
app
,
idmgr_name
)
token
=
mgr
.
getBrowserId
()
token
=
mgr
.
getBrowserId
()
bykeysd
=
self
.
app
.
session_data_manager
.
getSessionDataByKey
(
token
)
bykeysd
=
self
.
app
.
session_data_manager
.
getSessionDataByKey
(
token
)
self
.
failUnless
(
sd
==
bykeysd
)
self
.
assertTrue
(
sd
==
bykeysd
)
def
testBadExternalSDCPath
(
self
):
def
testBadExternalSDCPath
(
self
):
from
Products.Sessions.SessionDataManager
import
SessionDataManagerErr
from
Products.Sessions.SessionDataManager
import
SessionDataManagerErr
...
@@ -179,7 +179,7 @@ class TestSessionManager(unittest.TestCase):
...
@@ -179,7 +179,7 @@ class TestSessionManager(unittest.TestCase):
sd
=
sdm
.
getSessionData
()
sd
=
sdm
.
getSessionData
()
sd
[
'test'
]
=
'Its alive! Alive!'
sd
[
'test'
]
=
'Its alive! Alive!'
sd
.
invalidate
()
sd
.
invalidate
()
self
.
failUnless
(
not
sdm
.
getSessionData
().
has_key
(
'test'
))
self
.
assertTrue
(
not
sdm
.
getSessionData
().
has_key
(
'test'
))
def
testGhostUnghostSessionManager
(
self
):
def
testGhostUnghostSessionManager
(
self
):
import
transaction
import
transaction
...
@@ -189,7 +189,7 @@ class TestSessionManager(unittest.TestCase):
...
@@ -189,7 +189,7 @@ class TestSessionManager(unittest.TestCase):
sd
.
set
(
'foo'
,
'bar'
)
sd
.
set
(
'foo'
,
'bar'
)
sdm
.
_p_changed
=
None
sdm
.
_p_changed
=
None
transaction
.
commit
()
transaction
.
commit
()
self
.
failUnless
(
sdm
.
getSessionData
().
get
(
'foo'
)
==
'bar'
)
self
.
assertTrue
(
sdm
.
getSessionData
().
get
(
'foo'
)
==
'bar'
)
def
testSubcommitAssignsPJar
(
self
):
def
testSubcommitAssignsPJar
(
self
):
global
DummyPersistent
# so pickle can find it
global
DummyPersistent
# so pickle can find it
...
@@ -200,9 +200,9 @@ class TestSessionManager(unittest.TestCase):
...
@@ -200,9 +200,9 @@ class TestSessionManager(unittest.TestCase):
sd
=
self
.
app
.
session_data_manager
.
getSessionData
()
sd
=
self
.
app
.
session_data_manager
.
getSessionData
()
dummy
=
DummyPersistent
()
dummy
=
DummyPersistent
()
sd
.
set
(
'dp'
,
dummy
)
sd
.
set
(
'dp'
,
dummy
)
self
.
failUnless
(
sd
[
'dp'
].
_p_jar
is
None
)
self
.
assertTrue
(
sd
[
'dp'
].
_p_jar
is
None
)
transaction
.
savepoint
(
optimistic
=
True
)
transaction
.
savepoint
(
optimistic
=
True
)
self
.
failIf
(
sd
[
'dp'
].
_p_jar
is
None
)
self
.
assertFalse
(
sd
[
'dp'
].
_p_jar
is
None
)
def
testForeignObject
(
self
):
def
testForeignObject
(
self
):
from
ZODB.POSException
import
InvalidObjectReference
from
ZODB.POSException
import
InvalidObjectReference
...
@@ -237,7 +237,7 @@ class TestSessionManager(unittest.TestCase):
...
@@ -237,7 +237,7 @@ class TestSessionManager(unittest.TestCase):
self
.
app
.
REQUEST
[
'PARENTS'
]
=
[
self
.
app
]
self
.
app
.
REQUEST
[
'PARENTS'
]
=
[
self
.
app
]
self
.
app
.
REQUEST
[
'URL'
]
=
'a'
self
.
app
.
REQUEST
[
'URL'
]
=
'a'
self
.
app
.
REQUEST
.
traverse
(
'/'
)
self
.
app
.
REQUEST
.
traverse
(
'/'
)
self
.
failUnless
(
self
.
app
.
REQUEST
.
has_key
(
'TESTOFSESSION'
))
self
.
assertTrue
(
self
.
app
.
REQUEST
.
has_key
(
'TESTOFSESSION'
))
def
testUnlazifyAutoPopulated
(
self
):
def
testUnlazifyAutoPopulated
(
self
):
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
...
@@ -247,7 +247,7 @@ class TestSessionManager(unittest.TestCase):
...
@@ -247,7 +247,7 @@ class TestSessionManager(unittest.TestCase):
self
.
app
.
REQUEST
.
traverse
(
'/'
)
self
.
app
.
REQUEST
.
traverse
(
'/'
)
sess
=
self
.
app
.
REQUEST
[
'TESTOFSESSION'
]
sess
=
self
.
app
.
REQUEST
[
'TESTOFSESSION'
]
sdType
=
type
(
TransientObject
(
1
))
sdType
=
type
(
TransientObject
(
1
))
self
.
failUnless
(
type
(
aq_base
(
sess
))
is
sdType
)
self
.
assertTrue
(
type
(
aq_base
(
sess
))
is
sdType
)
def
test_suite
():
def
test_suite
():
...
...
src/Products/SiteAccess/tests/testAccessRule.py
View file @
6220f215
...
@@ -34,7 +34,7 @@ class AccessRuleTests(unittest.TestCase):
...
@@ -34,7 +34,7 @@ class AccessRuleTests(unittest.TestCase):
request
=
DummyRequest
(
TraversalRequestNameStack
=
[])
request
=
DummyRequest
(
TraversalRequestNameStack
=
[])
container
=
DummyContainer
(
testing
=
_func
)
container
=
DummyContainer
(
testing
=
_func
)
rule
(
container
,
request
)
rule
(
container
,
request
)
self
.
failIf
(
_called
)
self
.
assertFalse
(
_called
)
def
test___call___w_SUPPRESS_ACCESSRULE_in_URL
(
self
):
def
test___call___w_SUPPRESS_ACCESSRULE_in_URL
(
self
):
# This behavior changed in landing lp:142878.
# This behavior changed in landing lp:142878.
...
@@ -47,7 +47,7 @@ class AccessRuleTests(unittest.TestCase):
...
@@ -47,7 +47,7 @@ class AccessRuleTests(unittest.TestCase):
request
.
steps
=
[]
request
.
steps
=
[]
container
=
DummyContainer
(
testing
=
_func
)
container
=
DummyContainer
(
testing
=
_func
)
rule
(
container
,
request
)
rule
(
container
,
request
)
self
.
failUnless
(
_called
)
self
.
assertTrue
(
_called
)
self
.
assertEqual
(
request
.
_virtual_root
,
None
)
self
.
assertEqual
(
request
.
_virtual_root
,
None
)
def
test___call___wo_SUPPRESS_ACCESSRULE
(
self
):
def
test___call___wo_SUPPRESS_ACCESSRULE
(
self
):
...
@@ -59,7 +59,7 @@ class AccessRuleTests(unittest.TestCase):
...
@@ -59,7 +59,7 @@ class AccessRuleTests(unittest.TestCase):
request
.
steps
=
[]
request
.
steps
=
[]
container
=
DummyContainer
(
testing
=
_func
)
container
=
DummyContainer
(
testing
=
_func
)
rule
(
container
,
request
)
rule
(
container
,
request
)
self
.
failUnless
(
_called
)
self
.
assertTrue
(
_called
)
self
.
assertEqual
(
request
.
_virtual_root
,
None
)
self
.
assertEqual
(
request
.
_virtual_root
,
None
)
...
@@ -72,15 +72,15 @@ class Test_manage_addAccessRule(unittest.TestCase):
...
@@ -72,15 +72,15 @@ class Test_manage_addAccessRule(unittest.TestCase):
def
test_no_method_id_no_existing_rules_no_request
(
self
):
def
test_no_method_id_no_existing_rules_no_request
(
self
):
container
=
DummyContainer
()
container
=
DummyContainer
()
result
=
self
.
_callFUT
(
container
,
None
,
None
)
result
=
self
.
_callFUT
(
container
,
None
,
None
)
self
.
failUnless
(
result
is
None
)
self
.
assertTrue
(
result
is
None
)
self
.
failIf
(
container
.
__dict__
)
self
.
assertFalse
(
container
.
__dict__
)
def
test_no_method_id_no_existing_rules_w_request
(
self
):
def
test_no_method_id_no_existing_rules_w_request
(
self
):
container
=
DummyContainer
()
container
=
DummyContainer
()
result
=
self
.
_callFUT
(
container
,
None
,
{
'URL1'
:
'http://example.com/'
})
result
=
self
.
_callFUT
(
container
,
None
,
{
'URL1'
:
'http://example.com/'
})
self
.
failUnless
(
isinstance
(
result
,
str
))
self
.
assertTrue
(
isinstance
(
result
,
str
))
self
.
failUnless
(
'<TITLE>No Access Rule</TITLE>'
in
result
)
self
.
assertTrue
(
'<TITLE>No Access Rule</TITLE>'
in
result
)
self
.
failIf
(
container
.
__dict__
)
self
.
assertFalse
(
container
.
__dict__
)
def
test_no_method_id_w_existing_rules_no_request
(
self
):
def
test_no_method_id_w_existing_rules_no_request
(
self
):
from
ZPublisher.BeforeTraverse
import
registerBeforeTraverse
from
ZPublisher.BeforeTraverse
import
registerBeforeTraverse
...
@@ -89,9 +89,9 @@ class Test_manage_addAccessRule(unittest.TestCase):
...
@@ -89,9 +89,9 @@ class Test_manage_addAccessRule(unittest.TestCase):
icon
=
'rule_icon.jpg'
)
icon
=
'rule_icon.jpg'
)
registerBeforeTraverse
(
container
,
old_rule
,
'AccessRule'
)
registerBeforeTraverse
(
container
,
old_rule
,
'AccessRule'
)
result
=
self
.
_callFUT
(
container
,
None
,
None
)
result
=
self
.
_callFUT
(
container
,
None
,
None
)
self
.
failUnless
(
result
is
None
)
self
.
assertTrue
(
result
is
None
)
self
.
failIf
(
container
.
__before_traverse__
)
self
.
assertFalse
(
container
.
__before_traverse__
)
self
.
failIf
(
'icon'
in
old_rule
.
__dict__
)
self
.
assertFalse
(
'icon'
in
old_rule
.
__dict__
)
def
test_w_method_id_w_existing_rules_w_request_none
(
self
):
def
test_w_method_id_w_existing_rules_w_request_none
(
self
):
from
ZPublisher.BeforeTraverse
import
registerBeforeTraverse
from
ZPublisher.BeforeTraverse
import
registerBeforeTraverse
...
@@ -102,10 +102,10 @@ class Test_manage_addAccessRule(unittest.TestCase):
...
@@ -102,10 +102,10 @@ class Test_manage_addAccessRule(unittest.TestCase):
request
=
DummyRequest
(
URL1
=
'http://example.com/'
)
request
=
DummyRequest
(
URL1
=
'http://example.com/'
)
request
.
form
=
{
'none'
:
'1'
}
request
.
form
=
{
'none'
:
'1'
}
result
=
self
.
_callFUT
(
container
,
None
,
request
)
result
=
self
.
_callFUT
(
container
,
None
,
request
)
self
.
failUnless
(
isinstance
(
result
,
str
))
self
.
assertTrue
(
isinstance
(
result
,
str
))
self
.
failUnless
(
'<TITLE>No Access Rule</TITLE>'
in
result
)
self
.
assertTrue
(
'<TITLE>No Access Rule</TITLE>'
in
result
)
self
.
failIf
(
container
.
__before_traverse__
)
self
.
assertFalse
(
container
.
__before_traverse__
)
self
.
failIf
(
'icon'
in
old_rule
.
__dict__
)
self
.
assertFalse
(
'icon'
in
old_rule
.
__dict__
)
def
test_w_invalid_method_id_w_existing_rules_no_request
(
self
):
def
test_w_invalid_method_id_w_existing_rules_no_request
(
self
):
from
ZPublisher.BeforeTraverse
import
registerBeforeTraverse
from
ZPublisher.BeforeTraverse
import
registerBeforeTraverse
...
@@ -114,8 +114,8 @@ class Test_manage_addAccessRule(unittest.TestCase):
...
@@ -114,8 +114,8 @@ class Test_manage_addAccessRule(unittest.TestCase):
icon
=
'rule_icon.jpg'
)
icon
=
'rule_icon.jpg'
)
registerBeforeTraverse
(
container
,
old_rule
,
'AccessRule'
)
registerBeforeTraverse
(
container
,
old_rule
,
'AccessRule'
)
result
=
self
.
_callFUT
(
container
,
'nonesuch'
,
None
)
result
=
self
.
_callFUT
(
container
,
'nonesuch'
,
None
)
self
.
failUnless
(
result
is
None
)
self
.
assertTrue
(
result
is
None
)
self
.
failUnless
((
99
,
'AccessRule'
)
in
container
.
__before_traverse__
)
self
.
assertTrue
((
99
,
'AccessRule'
)
in
container
.
__before_traverse__
)
rule
=
container
.
__before_traverse__
[(
99
,
'AccessRule'
)]
rule
=
container
.
__before_traverse__
[(
99
,
'AccessRule'
)]
self
.
assertEqual
(
rule
.
name
,
'old_rule'
)
self
.
assertEqual
(
rule
.
name
,
'old_rule'
)
self
.
assertEqual
(
old_rule
.
icon
,
'rule_icon.jpg'
)
self
.
assertEqual
(
old_rule
.
icon
,
'rule_icon.jpg'
)
...
@@ -129,9 +129,9 @@ class Test_manage_addAccessRule(unittest.TestCase):
...
@@ -129,9 +129,9 @@ class Test_manage_addAccessRule(unittest.TestCase):
request
=
DummyRequest
(
URL1
=
'http://example.com/'
)
request
=
DummyRequest
(
URL1
=
'http://example.com/'
)
request
.
form
=
{}
request
.
form
=
{}
result
=
self
.
_callFUT
(
container
,
'nonesuch'
,
request
)
result
=
self
.
_callFUT
(
container
,
'nonesuch'
,
request
)
self
.
failUnless
(
isinstance
(
result
,
str
))
self
.
assertTrue
(
isinstance
(
result
,
str
))
self
.
failUnless
(
'<TITLE>Invalid Method Id</TITLE>'
in
result
)
self
.
assertTrue
(
'<TITLE>Invalid Method Id</TITLE>'
in
result
)
self
.
failUnless
((
99
,
'AccessRule'
)
in
container
.
__before_traverse__
)
self
.
assertTrue
((
99
,
'AccessRule'
)
in
container
.
__before_traverse__
)
rule
=
container
.
__before_traverse__
[(
99
,
'AccessRule'
)]
rule
=
container
.
__before_traverse__
[(
99
,
'AccessRule'
)]
self
.
assertEqual
(
rule
.
name
,
'old_rule'
)
self
.
assertEqual
(
rule
.
name
,
'old_rule'
)
self
.
assertEqual
(
old_rule
.
icon
,
'rule_icon.jpg'
)
self
.
assertEqual
(
old_rule
.
icon
,
'rule_icon.jpg'
)
...
@@ -144,12 +144,12 @@ class Test_manage_addAccessRule(unittest.TestCase):
...
@@ -144,12 +144,12 @@ class Test_manage_addAccessRule(unittest.TestCase):
new_rule
=
container
.
new_rule
=
DummyObject
(
name
=
'new_rule'
)
new_rule
=
container
.
new_rule
=
DummyObject
(
name
=
'new_rule'
)
registerBeforeTraverse
(
container
,
old_rule
,
'AccessRule'
)
registerBeforeTraverse
(
container
,
old_rule
,
'AccessRule'
)
result
=
self
.
_callFUT
(
container
,
'new_rule'
,
None
)
result
=
self
.
_callFUT
(
container
,
'new_rule'
,
None
)
self
.
failUnless
(
result
is
None
)
self
.
assertTrue
(
result
is
None
)
self
.
failIf
((
99
,
'AccessRule'
)
in
container
.
__before_traverse__
)
self
.
assertFalse
((
99
,
'AccessRule'
)
in
container
.
__before_traverse__
)
self
.
failUnless
((
1
,
'AccessRule'
)
in
container
.
__before_traverse__
)
self
.
assertTrue
((
1
,
'AccessRule'
)
in
container
.
__before_traverse__
)
rule
=
container
.
__before_traverse__
[(
1
,
'AccessRule'
)]
rule
=
container
.
__before_traverse__
[(
1
,
'AccessRule'
)]
self
.
assertEqual
(
rule
.
name
,
'new_rule'
)
self
.
assertEqual
(
rule
.
name
,
'new_rule'
)
self
.
failIf
(
'icon'
in
old_rule
.
__dict__
)
self
.
assertFalse
(
'icon'
in
old_rule
.
__dict__
)
self
.
assertEqual
(
new_rule
.
icon
,
'misc_/SiteAccess/AccessRule.gif'
)
self
.
assertEqual
(
new_rule
.
icon
,
'misc_/SiteAccess/AccessRule.gif'
)
def
test_w_valid_method_id_w_existing_rules_w_request
(
self
):
def
test_w_valid_method_id_w_existing_rules_w_request
(
self
):
...
@@ -162,13 +162,13 @@ class Test_manage_addAccessRule(unittest.TestCase):
...
@@ -162,13 +162,13 @@ class Test_manage_addAccessRule(unittest.TestCase):
request
=
DummyRequest
(
URL1
=
'http://example.com/'
)
request
=
DummyRequest
(
URL1
=
'http://example.com/'
)
request
.
form
=
{}
request
.
form
=
{}
result
=
self
.
_callFUT
(
container
,
'new_rule'
,
request
)
result
=
self
.
_callFUT
(
container
,
'new_rule'
,
request
)
self
.
failUnless
(
isinstance
(
result
,
str
))
self
.
assertTrue
(
isinstance
(
result
,
str
))
self
.
failUnless
(
'<TITLE>Access Rule Set</TITLE>'
in
result
)
self
.
assertTrue
(
'<TITLE>Access Rule Set</TITLE>'
in
result
)
self
.
failIf
((
99
,
'AccessRule'
)
in
container
.
__before_traverse__
)
self
.
assertFalse
((
99
,
'AccessRule'
)
in
container
.
__before_traverse__
)
self
.
failUnless
((
1
,
'AccessRule'
)
in
container
.
__before_traverse__
)
self
.
assertTrue
((
1
,
'AccessRule'
)
in
container
.
__before_traverse__
)
rule
=
container
.
__before_traverse__
[(
1
,
'AccessRule'
)]
rule
=
container
.
__before_traverse__
[(
1
,
'AccessRule'
)]
self
.
assertEqual
(
rule
.
name
,
'new_rule'
)
self
.
assertEqual
(
rule
.
name
,
'new_rule'
)
self
.
failIf
(
'icon'
in
old_rule
.
__dict__
)
self
.
assertFalse
(
'icon'
in
old_rule
.
__dict__
)
self
.
assertEqual
(
new_rule
.
icon
,
'misc_/SiteAccess/AccessRule.gif'
)
self
.
assertEqual
(
new_rule
.
icon
,
'misc_/SiteAccess/AccessRule.gif'
)
...
@@ -186,7 +186,7 @@ class Test_getAccessRule(unittest.TestCase):
...
@@ -186,7 +186,7 @@ class Test_getAccessRule(unittest.TestCase):
from
ZPublisher.BeforeTraverse
import
registerBeforeTraverse
from
ZPublisher.BeforeTraverse
import
registerBeforeTraverse
container
=
DummyContainer
()
container
=
DummyContainer
()
registerBeforeTraverse
(
container
,
DummyObject
(),
'AccessRule'
)
registerBeforeTraverse
(
container
,
DummyObject
(),
'AccessRule'
)
self
.
failUnless
(
self
.
_callFUT
(
container
).
startswith
(
self
.
assertTrue
(
self
.
_callFUT
(
container
).
startswith
(
'Invalid BeforeTraverse data: '
))
'Invalid BeforeTraverse data: '
))
def
test_w_rule_valid
(
self
):
def
test_w_rule_valid
(
self
):
...
...
src/Products/SiteAccess/tests/testSiteRoot.py
View file @
6220f215
...
@@ -23,7 +23,7 @@ class TraverserTests(unittest.TestCase):
...
@@ -23,7 +23,7 @@ class TraverserTests(unittest.TestCase):
traverser
=
self
.
_makeOne
()
traverser
=
self
.
_makeOne
()
container
=
DummyContainer
()
container
=
DummyContainer
()
traverser
.
addToContainer
(
container
)
traverser
.
addToContainer
(
container
)
self
.
failUnless
(
container
.
testing
is
traverser
)
self
.
assertTrue
(
container
.
testing
is
traverser
)
hook
=
container
.
__before_traverse__
[(
100
,
'Traverser'
)]
hook
=
container
.
__before_traverse__
[(
100
,
'Traverser'
)]
self
.
assertEqual
(
hook
.
name
,
'testing'
)
self
.
assertEqual
(
hook
.
name
,
'testing'
)
...
@@ -31,8 +31,8 @@ class TraverserTests(unittest.TestCase):
...
@@ -31,8 +31,8 @@ class TraverserTests(unittest.TestCase):
traverser
=
self
.
_makeOne
()
traverser
=
self
.
_makeOne
()
container
=
DummyContainer
()
container
=
DummyContainer
()
result
=
traverser
.
manage_addToContainer
(
container
)
result
=
traverser
.
manage_addToContainer
(
container
)
self
.
failUnless
(
result
is
None
)
self
.
assertTrue
(
result
is
None
)
self
.
failUnless
(
container
.
testing
is
traverser
)
self
.
assertTrue
(
container
.
testing
is
traverser
)
hook
=
container
.
__before_traverse__
[(
100
,
'Traverser'
)]
hook
=
container
.
__before_traverse__
[(
100
,
'Traverser'
)]
self
.
assertEqual
(
hook
.
name
,
'testing'
)
self
.
assertEqual
(
hook
.
name
,
'testing'
)
...
@@ -42,16 +42,16 @@ class TraverserTests(unittest.TestCase):
...
@@ -42,16 +42,16 @@ class TraverserTests(unittest.TestCase):
container
=
DummyContainer
()
container
=
DummyContainer
()
container
.
testing
=
object
()
container
.
testing
=
object
()
result
=
traverser
.
manage_addToContainer
(
container
,
nextURL
=
NEXTURL
)
result
=
traverser
.
manage_addToContainer
(
container
,
nextURL
=
NEXTURL
)
self
.
failUnless
(
'<TITLE>Item Exists</TITLE>'
in
result
)
self
.
assertTrue
(
'<TITLE>Item Exists</TITLE>'
in
result
)
self
.
failIf
(
container
.
testing
is
traverser
)
self
.
assertFalse
(
container
.
testing
is
traverser
)
def
test_manage_addToContainer_w_nextUrl_wo_name_collision
(
self
):
def
test_manage_addToContainer_w_nextUrl_wo_name_collision
(
self
):
NEXTURL
=
'http://example.com/manage_main'
NEXTURL
=
'http://example.com/manage_main'
traverser
=
self
.
_makeOne
()
traverser
=
self
.
_makeOne
()
container
=
DummyContainer
()
container
=
DummyContainer
()
result
=
traverser
.
manage_addToContainer
(
container
,
nextURL
=
NEXTURL
)
result
=
traverser
.
manage_addToContainer
(
container
,
nextURL
=
NEXTURL
)
self
.
failUnless
(
'<TITLE>Item Added</TITLE>'
in
result
)
self
.
assertTrue
(
'<TITLE>Item Added</TITLE>'
in
result
)
self
.
failUnless
(
container
.
testing
is
traverser
)
self
.
assertTrue
(
container
.
testing
is
traverser
)
hook
=
container
.
__before_traverse__
[(
100
,
'Traverser'
)]
hook
=
container
.
__before_traverse__
[(
100
,
'Traverser'
)]
self
.
assertEqual
(
hook
.
name
,
'testing'
)
self
.
assertEqual
(
hook
.
name
,
'testing'
)
...
@@ -73,14 +73,14 @@ class TraverserTests(unittest.TestCase):
...
@@ -73,14 +73,14 @@ class TraverserTests(unittest.TestCase):
other
=
container
.
other
=
DummyObject
(
name
=
'other'
)
other
=
container
.
other
=
DummyObject
(
name
=
'other'
)
registerBeforeTraverse
(
container
,
other
,
'Traverser'
,
100
)
registerBeforeTraverse
(
container
,
other
,
'Traverser'
,
100
)
traverser
.
manage_beforeDelete
(
traverser
,
container
)
traverser
.
manage_beforeDelete
(
traverser
,
container
)
self
.
failIf
(
container
.
__before_traverse__
)
self
.
assertFalse
(
container
.
__before_traverse__
)
def
test_manage_afterAdd_item_not_self
(
self
):
def
test_manage_afterAdd_item_not_self
(
self
):
traverser
=
self
.
_makeOne
()
traverser
=
self
.
_makeOne
()
container
=
DummyContainer
()
container
=
DummyContainer
()
item
=
object
()
item
=
object
()
traverser
.
manage_afterAdd
(
item
,
container
)
traverser
.
manage_afterAdd
(
item
,
container
)
self
.
failIf
(
'__before_traverse__'
in
container
.
__dict__
)
self
.
assertFalse
(
'__before_traverse__'
in
container
.
__dict__
)
def
test_manage_afterAdd_item_is_self
(
self
):
def
test_manage_afterAdd_item_is_self
(
self
):
traverser
=
self
.
_makeOne
()
traverser
=
self
.
_makeOne
()
...
@@ -140,7 +140,7 @@ class SiteRootTests(unittest.TestCase):
...
@@ -140,7 +140,7 @@ class SiteRootTests(unittest.TestCase):
path
=
'/before'
)
path
=
'/before'
)
result
=
siteroot
.
manage_edit
(
'After'
,
'http://after.example.com '
,
result
=
siteroot
.
manage_edit
(
'After'
,
'http://after.example.com '
,
'/after '
)
'/after '
)
self
.
failUnless
(
result
is
None
)
self
.
assertTrue
(
result
is
None
)
self
.
assertEqual
(
siteroot
.
title
,
'After'
)
self
.
assertEqual
(
siteroot
.
title
,
'After'
)
self
.
assertEqual
(
siteroot
.
base
,
'http://after.example.com'
)
self
.
assertEqual
(
siteroot
.
base
,
'http://after.example.com'
)
self
.
assertEqual
(
siteroot
.
path
,
'/after'
)
self
.
assertEqual
(
siteroot
.
path
,
'/after'
)
...
@@ -153,7 +153,7 @@ class SiteRootTests(unittest.TestCase):
...
@@ -153,7 +153,7 @@ class SiteRootTests(unittest.TestCase):
'/after '
,
'/after '
,
REQUEST
=
{
'URL1'
:
REQUEST
=
{
'URL1'
:
'http://localhost:8080/manage_main'
})
'http://localhost:8080/manage_main'
})
self
.
failUnless
(
'<TITLE>SiteRoot changed.</TITLE>'
in
result
)
self
.
assertTrue
(
'<TITLE>SiteRoot changed.</TITLE>'
in
result
)
self
.
assertEqual
(
siteroot
.
title
,
'After'
)
self
.
assertEqual
(
siteroot
.
title
,
'After'
)
self
.
assertEqual
(
siteroot
.
base
,
'http://after.example.com'
)
self
.
assertEqual
(
siteroot
.
base
,
'http://after.example.com'
)
self
.
assertEqual
(
siteroot
.
path
,
'/after'
)
self
.
assertEqual
(
siteroot
.
path
,
'/after'
)
...
@@ -183,7 +183,7 @@ class SiteRootTests(unittest.TestCase):
...
@@ -183,7 +183,7 @@ class SiteRootTests(unittest.TestCase):
self
.
assertEqual
(
request
[
'ACTUAL_URL'
],
self
.
assertEqual
(
request
[
'ACTUAL_URL'
],
'http://example.com/example/folder/'
)
'http://example.com/example/folder/'
)
self
.
assertEqual
(
request
.
_virtual_root
,
'/example'
)
self
.
assertEqual
(
request
.
_virtual_root
,
'/example'
)
self
.
failUnless
(
request
.
_urls_reset
)
self
.
assertTrue
(
request
.
_urls_reset
)
def
test___call___wo_SUPPRESS_SITEROOT_w_base_wo_path
(
self
):
def
test___call___wo_SUPPRESS_SITEROOT_w_base_wo_path
(
self
):
URL
=
'http://localhost:8080/example/folder/'
URL
=
'http://localhost:8080/example/folder/'
...
@@ -201,7 +201,7 @@ class SiteRootTests(unittest.TestCase):
...
@@ -201,7 +201,7 @@ class SiteRootTests(unittest.TestCase):
self
.
assertEqual
(
request
[
'ACTUAL_URL'
],
self
.
assertEqual
(
request
[
'ACTUAL_URL'
],
'http://example.com/example/folder/'
)
'http://example.com/example/folder/'
)
self
.
assertEqual
(
request
.
_virtual_root
,
None
)
self
.
assertEqual
(
request
.
_virtual_root
,
None
)
self
.
failUnless
(
request
.
_urls_reset
)
self
.
assertTrue
(
request
.
_urls_reset
)
def
test___call___wo_SUPPRESS_SITEROOT_wo_base_w_path
(
self
):
def
test___call___wo_SUPPRESS_SITEROOT_wo_base_w_path
(
self
):
URL
=
'http://localhost:8080/example/folder/'
URL
=
'http://localhost:8080/example/folder/'
...
@@ -218,7 +218,7 @@ class SiteRootTests(unittest.TestCase):
...
@@ -218,7 +218,7 @@ class SiteRootTests(unittest.TestCase):
self
.
assertEqual
(
request
[
'SERVER_URL'
],
'http://localhost:8080'
)
self
.
assertEqual
(
request
[
'SERVER_URL'
],
'http://localhost:8080'
)
self
.
assertEqual
(
request
[
'ACTUAL_URL'
],
URL
)
self
.
assertEqual
(
request
[
'ACTUAL_URL'
],
URL
)
self
.
assertEqual
(
request
.
_virtual_root
,
'/example'
)
self
.
assertEqual
(
request
.
_virtual_root
,
'/example'
)
self
.
failIf
(
request
.
_urls_reset
)
self
.
assertFalse
(
request
.
_urls_reset
)
def
test___call___wo_SUPPRESS_SITEROOT_w_base_w_path
(
self
):
def
test___call___wo_SUPPRESS_SITEROOT_w_base_w_path
(
self
):
URL
=
'http://localhost:8080/example/folder/'
URL
=
'http://localhost:8080/example/folder/'
...
@@ -236,7 +236,7 @@ class SiteRootTests(unittest.TestCase):
...
@@ -236,7 +236,7 @@ class SiteRootTests(unittest.TestCase):
self
.
assertEqual
(
request
[
'ACTUAL_URL'
],
self
.
assertEqual
(
request
[
'ACTUAL_URL'
],
'http://example.com/example/folder/'
)
'http://example.com/example/folder/'
)
self
.
assertEqual
(
request
.
_virtual_root
,
'/example'
)
self
.
assertEqual
(
request
.
_virtual_root
,
'/example'
)
self
.
failUnless
(
request
.
_urls_reset
)
self
.
assertTrue
(
request
.
_urls_reset
)
def
test_get_size
(
self
):
def
test_get_size
(
self
):
siteroot
=
self
.
_makeOne
()
siteroot
=
self
.
_makeOne
()
...
...
src/Products/SiteAccess/tests/testVirtualHostMonster.py
View file @
6220f215
...
@@ -184,8 +184,8 @@ class VHMAddingTests(unittest.TestCase):
...
@@ -184,8 +184,8 @@ class VHMAddingTests(unittest.TestCase):
vhm1
=
self
.
_makeOne
()
vhm1
=
self
.
_makeOne
()
vhm1
.
manage_addToContainer
(
self
.
root
)
vhm1
.
manage_addToContainer
(
self
.
root
)
self
.
failUnless
(
vhm1
.
getId
()
in
self
.
root
.
objectIds
())
self
.
assertTrue
(
vhm1
.
getId
()
in
self
.
root
.
objectIds
())
self
.
failUnless
(
queryBeforeTraverse
(
self
.
root
,
vhm1
.
meta_type
))
self
.
assertTrue
(
queryBeforeTraverse
(
self
.
root
,
vhm1
.
meta_type
))
def
test_add_manage_addVirtualHostMonster
(
self
):
def
test_add_manage_addVirtualHostMonster
(
self
):
from
Products.SiteAccess.VirtualHostMonster
import
\
from
Products.SiteAccess.VirtualHostMonster
import
\
...
@@ -194,9 +194,9 @@ class VHMAddingTests(unittest.TestCase):
...
@@ -194,9 +194,9 @@ class VHMAddingTests(unittest.TestCase):
from
ZPublisher.BeforeTraverse
import
queryBeforeTraverse
from
ZPublisher.BeforeTraverse
import
queryBeforeTraverse
manage_addVirtualHostMonster
(
self
.
root
)
manage_addVirtualHostMonster
(
self
.
root
)
self
.
failUnless
(
VirtualHostMonster
.
id
in
self
.
root
.
objectIds
())
self
.
assertTrue
(
VirtualHostMonster
.
id
in
self
.
root
.
objectIds
())
hook
=
queryBeforeTraverse
(
self
.
root
,
VirtualHostMonster
.
meta_type
)
hook
=
queryBeforeTraverse
(
self
.
root
,
VirtualHostMonster
.
meta_type
)
self
.
failUnless
(
hook
)
self
.
assertTrue
(
hook
)
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
...
...
src/Products/Transience/tests/testTransientObject.py
View file @
6220f215
...
@@ -43,7 +43,7 @@ class TestTransientObject(TestCase):
...
@@ -43,7 +43,7 @@ class TestTransientObject(TestCase):
t
=
self
.
t
.
new
(
'xyzzy'
)
t
=
self
.
t
.
new
(
'xyzzy'
)
self
.
assert_
(
t
.
isValid
())
self
.
assert_
(
t
.
isValid
())
t
.
invalidate
()
t
.
invalidate
()
self
.
failIf
(
t
.
isValid
())
self
.
assertFalse
(
t
.
isValid
())
def
test_getLastAccessed
(
self
):
def
test_getLastAccessed
(
self
):
t
=
self
.
t
.
new
(
'xyzzy'
)
t
=
self
.
t
.
new
(
'xyzzy'
)
...
@@ -98,7 +98,7 @@ class TestTransientObject(TestCase):
...
@@ -98,7 +98,7 @@ class TestTransientObject(TestCase):
self
.
assertRaises
(
AttributeError
,
self
.
_genLenError
,
t
)
self
.
assertRaises
(
AttributeError
,
self
.
_genLenError
,
t
)
self
.
assertEqual
(
t
.
get
(
'foobie'
,
None
),
None
)
self
.
assertEqual
(
t
.
get
(
'foobie'
,
None
),
None
)
self
.
assert_
(
t
.
has_key
(
'a'
))
self
.
assert_
(
t
.
has_key
(
'a'
))
self
.
failIf
(
t
.
has_key
(
'foobie'
))
self
.
assertFalse
(
t
.
has_key
(
'foobie'
))
t
.
clear
()
t
.
clear
()
self
.
assertEqual
(
len
(
t
.
keys
()),
0
)
self
.
assertEqual
(
len
(
t
.
keys
()),
0
)
...
@@ -116,7 +116,7 @@ class TestTransientObject(TestCase):
...
@@ -116,7 +116,7 @@ class TestTransientObject(TestCase):
# information being visible in e.g. the ErrorLog object.
# information being visible in e.g. the ErrorLog object.
t
=
self
.
t
.
new
(
'password-storing-session'
)
t
=
self
.
t
.
new
(
'password-storing-session'
)
t
.
set
(
'__ac_password__'
,
'secret'
)
t
.
set
(
'__ac_password__'
,
'secret'
)
self
.
failIf
(
repr
(
t
).
find
(
'secret'
)
!=
-
1
self
.
assertFalse
(
repr
(
t
).
find
(
'secret'
)
!=
-
1
,
'__repr__ leaks: %s'
%
repr
(
t
)
,
'__repr__ leaks: %s'
%
repr
(
t
)
)
)
...
...
src/Products/Transience/tests/testTransientObjectContainer.py
View file @
6220f215
...
@@ -65,7 +65,7 @@ class TestTransientObjectContainer(TestCase):
...
@@ -65,7 +65,7 @@ class TestTransientObjectContainer(TestCase):
def
testHasKeyWorks
(
self
):
def
testHasKeyWorks
(
self
):
self
.
t
[
10
]
=
1
self
.
t
[
10
]
=
1
self
.
failUnless
(
self
.
t
.
has_key
(
10
))
self
.
assertTrue
(
self
.
t
.
has_key
(
10
))
def
testValuesWorks
(
self
):
def
testValuesWorks
(
self
):
for
x
in
range
(
10
,
110
):
for
x
in
range
(
10
,
110
):
...
@@ -234,7 +234,7 @@ class TestTransientObjectContainer(TestCase):
...
@@ -234,7 +234,7 @@ class TestTransientObjectContainer(TestCase):
for
x
in
delete_order
:
for
x
in
delete_order
:
try
:
del
self
.
t
[
x
]
try
:
del
self
.
t
[
x
]
except
KeyError
:
except
KeyError
:
self
.
failIf
(
self
.
t
.
has_key
(
x
))
self
.
assertFalse
(
self
.
t
.
has_key
(
x
))
def
testGetDelaysTimeout
(
self
):
def
testGetDelaysTimeout
(
self
):
for
x
in
range
(
10
,
110
):
for
x
in
range
(
10
,
110
):
...
@@ -283,7 +283,7 @@ class TestTransientObjectContainer(TestCase):
...
@@ -283,7 +283,7 @@ class TestTransientObjectContainer(TestCase):
def
testResetWorks
(
self
):
def
testResetWorks
(
self
):
self
.
t
[
10
]
=
1
self
.
t
[
10
]
=
1
self
.
t
.
_reset
()
self
.
t
.
_reset
()
self
.
failIf
(
self
.
t
.
get
(
10
))
self
.
assertFalse
(
self
.
t
.
get
(
10
))
def
testGetTimeoutMinutesWorks
(
self
):
def
testGetTimeoutMinutesWorks
(
self
):
self
.
assertEqual
(
self
.
t
.
getTimeoutMinutes
(),
self
.
timeout
/
60
)
self
.
assertEqual
(
self
.
t
.
getTimeoutMinutes
(),
self
.
timeout
/
60
)
...
@@ -293,7 +293,7 @@ class TestTransientObjectContainer(TestCase):
...
@@ -293,7 +293,7 @@ class TestTransientObjectContainer(TestCase):
def
test_new
(
self
):
def
test_new
(
self
):
t
=
self
.
t
.
new
(
'foobieblech'
)
t
=
self
.
t
.
new
(
'foobieblech'
)
self
.
failUnless
(
issubclass
(
t
.
__class__
,
TransientObject
))
self
.
assertTrue
(
issubclass
(
t
.
__class__
,
TransientObject
))
def
_dupNewItem
(
self
):
def
_dupNewItem
(
self
):
self
.
t
.
new
(
'foobieblech'
)
self
.
t
.
new
(
'foobieblech'
)
...
...
src/Products/ZCatalog/tests/test_brains.py
View file @
6220f215
...
@@ -115,9 +115,9 @@ class TestBrains(unittest.TestCase):
...
@@ -115,9 +115,9 @@ class TestBrains(unittest.TestCase):
def
testHasKey
(
self
):
def
testHasKey
(
self
):
b
=
self
.
_makeBrain
(
1
)
b
=
self
.
_makeBrain
(
1
)
self
.
failUnless
(
'test_field'
in
b
)
self
.
assertTrue
(
'test_field'
in
b
)
self
.
failUnless
(
'data_record_id_'
in
b
)
self
.
assertTrue
(
'data_record_id_'
in
b
)
self
.
failIf
(
'godel'
in
b
)
self
.
assertFalse
(
'godel'
in
b
)
def
testGetPath
(
self
):
def
testGetPath
(
self
):
b
=
[
self
.
_makeBrain
(
rid
)
for
rid
in
range
(
3
)]
b
=
[
self
.
_makeBrain
(
rid
)
for
rid
in
range
(
3
)]
...
@@ -141,7 +141,7 @@ class TestBrains(unittest.TestCase):
...
@@ -141,7 +141,7 @@ class TestBrains(unittest.TestCase):
def
testGetObjectHappy
(
self
):
def
testGetObjectHappy
(
self
):
b
=
self
.
_makeBrain
(
1
)
b
=
self
.
_makeBrain
(
1
)
self
.
assertEqual
(
b
.
getPath
(),
'/happy'
)
self
.
assertEqual
(
b
.
getPath
(),
'/happy'
)
self
.
failUnless
(
aq_base
(
b
.
getObject
())
is
self
.
assertTrue
(
aq_base
(
b
.
getObject
())
is
aq_base
(
self
.
cat
.
getobject
(
1
)))
aq_base
(
self
.
cat
.
getobject
(
1
)))
def
testGetObjectPropagatesConflictErrors
(
self
):
def
testGetObjectPropagatesConflictErrors
(
self
):
...
...
src/Products/ZCatalog/tests/test_zcatalog.py
View file @
6220f215
...
@@ -390,7 +390,7 @@ class TestZCatalogGetObject(ZCatalogBase, unittest.TestCase):
...
@@ -390,7 +390,7 @@ class TestZCatalogGetObject(ZCatalogBase, unittest.TestCase):
pickySecurityManager
=
PickySecurityManager
([
'fold'
])
pickySecurityManager
=
PickySecurityManager
([
'fold'
])
setSecurityManager
(
pickySecurityManager
)
setSecurityManager
(
pickySecurityManager
)
ob
=
brain
.
getObject
()
ob
=
brain
.
getObject
()
self
.
failIf
(
ob
is
None
)
self
.
assertFalse
(
ob
is
None
)
self
.
assertEqual
(
ob
.
getId
(),
'ob'
)
self
.
assertEqual
(
ob
.
getId
(),
'ob'
)
# Now test _unrestrictedGetObject
# Now test _unrestrictedGetObject
...
...
src/Products/ZReST/tests/test_ZReST.py
View file @
6220f215
...
@@ -57,7 +57,7 @@ class TestZReST(unittest.TestCase):
...
@@ -57,7 +57,7 @@ class TestZReST(unittest.TestCase):
resty
=
self
.
_makeOne
()
resty
=
self
.
_makeOne
()
resty
.
formatted
=
'IGNORE ME'
resty
.
formatted
=
'IGNORE ME'
self
.
failIf
(
'IGNORE ME'
in
resty
.
index_html
())
self
.
assertFalse
(
'IGNORE ME'
in
resty
.
index_html
())
def
testConversion
(
self
):
def
testConversion
(
self
):
resty
=
self
.
_makeOne
()
resty
=
self
.
_makeOne
()
...
@@ -129,7 +129,7 @@ class TestZReST(unittest.TestCase):
...
@@ -129,7 +129,7 @@ class TestZReST(unittest.TestCase):
csv_file
=
self
.
_csvfile
()
csv_file
=
self
.
_csvfile
()
resty
.
source
=
'.. csv-table::
\
n
:file: %s'
%
csv_file
resty
.
source
=
'.. csv-table::
\
n
:file: %s'
%
csv_file
result
=
resty
.
render
()
result
=
resty
.
render
()
self
.
failUnless
(
'daemon'
not
in
result
,
self
.
assertTrue
(
'daemon'
not
in
result
,
'csv-table/file directive is not disabled!'
)
'csv-table/file directive is not disabled!'
)
def
test_csv_table_url_option_raise
(
self
):
def
test_csv_table_url_option_raise
(
self
):
...
@@ -137,7 +137,7 @@ class TestZReST(unittest.TestCase):
...
@@ -137,7 +137,7 @@ class TestZReST(unittest.TestCase):
csv_file
=
self
.
_csvfile
()
csv_file
=
self
.
_csvfile
()
resty
.
source
=
'.. csv-table::
\
n
:url: file://%s'
%
csv_file
resty
.
source
=
'.. csv-table::
\
n
:url: file://%s'
%
csv_file
result
=
resty
.
render
()
result
=
resty
.
render
()
self
.
failUnless
(
'daemon'
not
in
result
,
self
.
assertTrue
(
'daemon'
not
in
result
,
'csv-table/url directive is not disabled!'
)
'csv-table/url directive is not disabled!'
)
...
...
src/Testing/ZopeTestCase/testFunctional.py
View file @
6220f215
...
@@ -134,7 +134,7 @@ class TestFunctional(ZopeTestCase.FunctionalTestCase):
...
@@ -134,7 +134,7 @@ class TestFunctional(ZopeTestCase.FunctionalTestCase):
basic
=
self
.
basic_auth
)
basic
=
self
.
basic_auth
)
self
.
assertEqual
(
response
.
getStatus
(),
201
)
self
.
assertEqual
(
response
.
getStatus
(),
201
)
self
.
failUnless
(
'new_document'
in
self
.
folder
.
objectIds
())
self
.
assertTrue
(
'new_document'
in
self
.
folder
.
objectIds
())
self
.
assertEqual
(
self
.
folder
.
new_document
.
meta_type
,
'DTML Document'
)
self
.
assertEqual
(
self
.
folder
.
new_document
.
meta_type
,
'DTML Document'
)
self
.
assertEqual
(
self
.
folder
.
new_document
(),
'foo'
)
self
.
assertEqual
(
self
.
folder
.
new_document
(),
'foo'
)
...
...
src/Testing/ZopeTestCase/testInterfaces.py
View file @
6220f215
...
@@ -23,14 +23,14 @@ from zope.interface.verify import verifyObject
...
@@ -23,14 +23,14 @@ from zope.interface.verify import verifyObject
class
TestAbstractClasses
(
TestCase
):
class
TestAbstractClasses
(
TestCase
):
def
testIFunctional
(
self
):
def
testIFunctional
(
self
):
self
.
failUnless
(
verifyClass
(
IFunctional
,
Functional
))
self
.
assertTrue
(
verifyClass
(
IFunctional
,
Functional
))
class
TestBaseTestCase
(
TestCase
):
class
TestBaseTestCase
(
TestCase
):
def
testIZopeTestCase
(
self
):
def
testIZopeTestCase
(
self
):
self
.
failUnless
(
verifyClass
(
IZopeTestCase
,
TestCase
))
self
.
assertTrue
(
verifyClass
(
IZopeTestCase
,
TestCase
))
self
.
failUnless
(
verifyObject
(
IZopeTestCase
,
self
))
self
.
assertTrue
(
verifyObject
(
IZopeTestCase
,
self
))
class
TestZopeTestCase
(
ZopeTestCase
):
class
TestZopeTestCase
(
ZopeTestCase
):
...
@@ -38,12 +38,12 @@ class TestZopeTestCase(ZopeTestCase):
...
@@ -38,12 +38,12 @@ class TestZopeTestCase(ZopeTestCase):
_setup_fixture
=
0
_setup_fixture
=
0
def
testIZopeTestCase
(
self
):
def
testIZopeTestCase
(
self
):
self
.
failUnless
(
verifyClass
(
IZopeTestCase
,
ZopeTestCase
))
self
.
assertTrue
(
verifyClass
(
IZopeTestCase
,
ZopeTestCase
))
self
.
failUnless
(
verifyObject
(
IZopeTestCase
,
self
))
self
.
assertTrue
(
verifyObject
(
IZopeTestCase
,
self
))
def
testIZopeSecurity
(
self
):
def
testIZopeSecurity
(
self
):
self
.
failUnless
(
verifyClass
(
IZopeSecurity
,
ZopeTestCase
))
self
.
assertTrue
(
verifyClass
(
IZopeSecurity
,
ZopeTestCase
))
self
.
failUnless
(
verifyObject
(
IZopeSecurity
,
self
))
self
.
assertTrue
(
verifyObject
(
IZopeSecurity
,
self
))
class
TestFunctionalTestCase
(
FunctionalTestCase
):
class
TestFunctionalTestCase
(
FunctionalTestCase
):
...
@@ -51,16 +51,16 @@ class TestFunctionalTestCase(FunctionalTestCase):
...
@@ -51,16 +51,16 @@ class TestFunctionalTestCase(FunctionalTestCase):
_setup_fixture
=
0
_setup_fixture
=
0
def
testIFunctional
(
self
):
def
testIFunctional
(
self
):
self
.
failUnless
(
verifyClass
(
IFunctional
,
FunctionalTestCase
))
self
.
assertTrue
(
verifyClass
(
IFunctional
,
FunctionalTestCase
))
self
.
failUnless
(
verifyObject
(
IFunctional
,
self
))
self
.
assertTrue
(
verifyObject
(
IFunctional
,
self
))
def
testIZopeTestCase
(
self
):
def
testIZopeTestCase
(
self
):
self
.
failUnless
(
verifyClass
(
IZopeTestCase
,
FunctionalTestCase
))
self
.
assertTrue
(
verifyClass
(
IZopeTestCase
,
FunctionalTestCase
))
self
.
failUnless
(
verifyObject
(
IZopeTestCase
,
self
))
self
.
assertTrue
(
verifyObject
(
IZopeTestCase
,
self
))
def
testIZopeSecurity
(
self
):
def
testIZopeSecurity
(
self
):
self
.
failUnless
(
verifyClass
(
IZopeSecurity
,
FunctionalTestCase
))
self
.
assertTrue
(
verifyClass
(
IZopeSecurity
,
FunctionalTestCase
))
self
.
failUnless
(
verifyObject
(
IZopeSecurity
,
self
))
self
.
assertTrue
(
verifyObject
(
IZopeSecurity
,
self
))
class
TestPortalTestCase
(
PortalTestCase
):
class
TestPortalTestCase
(
PortalTestCase
):
...
@@ -71,16 +71,16 @@ class TestPortalTestCase(PortalTestCase):
...
@@ -71,16 +71,16 @@ class TestPortalTestCase(PortalTestCase):
return
None
return
None
def
testIZopeTestCase
(
self
):
def
testIZopeTestCase
(
self
):
self
.
failUnless
(
verifyClass
(
IZopeTestCase
,
PortalTestCase
))
self
.
assertTrue
(
verifyClass
(
IZopeTestCase
,
PortalTestCase
))
self
.
failUnless
(
verifyObject
(
IZopeTestCase
,
self
))
self
.
assertTrue
(
verifyObject
(
IZopeTestCase
,
self
))
def
testIPortalTestCase
(
self
):
def
testIPortalTestCase
(
self
):
self
.
failUnless
(
verifyClass
(
IPortalTestCase
,
PortalTestCase
))
self
.
assertTrue
(
verifyClass
(
IPortalTestCase
,
PortalTestCase
))
self
.
failUnless
(
verifyObject
(
IPortalTestCase
,
self
))
self
.
assertTrue
(
verifyObject
(
IPortalTestCase
,
self
))
def
testIPortalSecurity
(
self
):
def
testIPortalSecurity
(
self
):
self
.
failUnless
(
verifyClass
(
IPortalSecurity
,
PortalTestCase
))
self
.
assertTrue
(
verifyClass
(
IPortalSecurity
,
PortalTestCase
))
self
.
failUnless
(
verifyObject
(
IPortalSecurity
,
self
))
self
.
assertTrue
(
verifyObject
(
IPortalSecurity
,
self
))
def
test_suite
():
def
test_suite
():
...
...
src/Testing/ZopeTestCase/testPortalTestCase.py
View file @
6220f215
...
@@ -109,18 +109,18 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -109,18 +109,18 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
# Portal should be set up
# Portal should be set up
self
.
app
=
self
.
_app
()
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
_portal
()
self
.
portal
=
self
.
_portal
()
self
.
failUnless
(
hasattr_
(
self
.
app
,
portal_name
))
self
.
assertTrue
(
hasattr_
(
self
.
app
,
portal_name
))
self
.
failUnless
(
hasattr_
(
self
.
portal
,
'Members'
))
self
.
assertTrue
(
hasattr_
(
self
.
portal
,
'Members'
))
self
.
failUnless
(
hasattr_
(
self
.
portal
,
'portal_membership'
))
self
.
assertTrue
(
hasattr_
(
self
.
portal
,
'portal_membership'
))
self
.
failUnless
(
'Member'
in
self
.
portal
.
userdefined_roles
())
self
.
assertTrue
(
'Member'
in
self
.
portal
.
userdefined_roles
())
def
test_setupUserFolder
(
self
):
def
test_setupUserFolder
(
self
):
# User folder should be set up.
# User folder should be set up.
self
.
app
=
self
.
_app
()
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
_portal
()
self
.
portal
=
self
.
_portal
()
self
.
failIf
(
hasattr_
(
self
.
portal
,
'acl_users'
))
self
.
assertFalse
(
hasattr_
(
self
.
portal
,
'acl_users'
))
self
.
_setupUserFolder
()
self
.
_setupUserFolder
()
self
.
failUnless
(
hasattr_
(
self
.
portal
,
'acl_users'
))
self
.
assertTrue
(
hasattr_
(
self
.
portal
,
'acl_users'
))
# Must not complain if UF already exists
# Must not complain if UF already exists
self
.
_setupUserFolder
()
self
.
_setupUserFolder
()
...
@@ -131,7 +131,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -131,7 +131,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
self
.
_setupUserFolder
()
self
.
_setupUserFolder
()
self
.
_setupUser
()
self
.
_setupUser
()
acl_user
=
self
.
portal
.
acl_users
.
getUserById
(
user_name
)
acl_user
=
self
.
portal
.
acl_users
.
getUserById
(
user_name
)
self
.
failUnless
(
acl_user
)
self
.
assertTrue
(
acl_user
)
self
.
assertEqual
(
acl_user
.
getRoles
(),
(
'Member'
,
'Authenticated'
))
self
.
assertEqual
(
acl_user
.
getRoles
(),
(
'Member'
,
'Authenticated'
))
self
.
assertEqual
(
type
(
acl_user
.
roles
),
ListType
)
self
.
assertEqual
(
type
(
acl_user
.
roles
),
ListType
)
...
@@ -143,8 +143,8 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -143,8 +143,8 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
self
.
_setupUser
()
self
.
_setupUser
()
self
.
login
()
self
.
login
()
self
.
_setupHomeFolder
()
self
.
_setupHomeFolder
()
self
.
failUnless
(
hasattr_
(
self
.
portal
.
Members
,
user_name
))
self
.
assertTrue
(
hasattr_
(
self
.
portal
.
Members
,
user_name
))
self
.
failIf
(
self
.
folder
is
None
)
self
.
assertFalse
(
self
.
folder
is
None
)
# Shut up deprecation warnings
# Shut up deprecation warnings
try
:
owner_info
=
self
.
folder
.
getOwnerTuple
()
try
:
owner_info
=
self
.
folder
.
getOwnerTuple
()
except
AttributeError
:
except
AttributeError
:
...
@@ -298,7 +298,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -298,7 +298,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
self
.
_setupUser
()
self
.
_setupUser
()
self
.
_setupHomeFolder
()
self
.
_setupHomeFolder
()
self
.
_clear
(
1
)
self
.
_clear
(
1
)
self
.
failIf
(
self
.
app
.
__dict__
.
has_key
(
portal_name
))
self
.
assertFalse
(
self
.
app
.
__dict__
.
has_key
(
portal_name
))
auth_name
=
getSecurityManager
().
getUser
().
getUserName
()
auth_name
=
getSecurityManager
().
getUser
().
getUserName
()
self
.
assertEqual
(
auth_name
,
'Anonymous User'
)
self
.
assertEqual
(
auth_name
,
'Anonymous User'
)
self
.
assertEqual
(
self
.
_called
,
[
'beforeClose'
,
'afterClear'
])
self
.
assertEqual
(
self
.
_called
,
[
'beforeClose'
,
'afterClear'
])
...
@@ -308,14 +308,14 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -308,14 +308,14 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_setUp
(
self
):
def
test_setUp
(
self
):
# Everything should be set up
# Everything should be set up
self
.
_setUp
()
self
.
_setUp
()
self
.
failUnless
(
hasattr_
(
self
.
app
,
portal_name
))
self
.
assertTrue
(
hasattr_
(
self
.
app
,
portal_name
))
self
.
failUnless
(
hasattr_
(
self
.
portal
,
'acl_users'
))
self
.
assertTrue
(
hasattr_
(
self
.
portal
,
'acl_users'
))
self
.
failUnless
(
hasattr_
(
self
.
portal
,
'Members'
))
self
.
assertTrue
(
hasattr_
(
self
.
portal
,
'Members'
))
self
.
failUnless
(
hasattr_
(
self
.
portal
,
'portal_membership'
))
self
.
assertTrue
(
hasattr_
(
self
.
portal
,
'portal_membership'
))
self
.
failUnless
(
'Member'
in
self
.
portal
.
userdefined_roles
())
self
.
assertTrue
(
'Member'
in
self
.
portal
.
userdefined_roles
())
self
.
failUnless
(
hasattr_
(
self
.
portal
.
Members
,
user_name
))
self
.
assertTrue
(
hasattr_
(
self
.
portal
.
Members
,
user_name
))
acl_user
=
self
.
portal
.
acl_users
.
getUserById
(
user_name
)
acl_user
=
self
.
portal
.
acl_users
.
getUserById
(
user_name
)
self
.
failUnless
(
acl_user
)
self
.
assertTrue
(
acl_user
)
self
.
assertEqual
(
acl_user
.
getRoles
(),
(
'Member'
,
'Authenticated'
))
self
.
assertEqual
(
acl_user
.
getRoles
(),
(
'Member'
,
'Authenticated'
))
self
.
assertEqual
(
type
(
acl_user
.
roles
),
ListType
)
self
.
assertEqual
(
type
(
acl_user
.
roles
),
ListType
)
auth_name
=
getSecurityManager
().
getUser
().
getId
()
auth_name
=
getSecurityManager
().
getUser
().
getId
()
...
@@ -329,7 +329,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -329,7 +329,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
self
.
_setUp
()
self
.
_setUp
()
self
.
_called
=
[]
self
.
_called
=
[]
self
.
_tearDown
()
self
.
_tearDown
()
self
.
failIf
(
self
.
app
.
__dict__
.
has_key
(
portal_name
))
self
.
assertFalse
(
self
.
app
.
__dict__
.
has_key
(
portal_name
))
auth_name
=
getSecurityManager
().
getUser
().
getUserName
()
auth_name
=
getSecurityManager
().
getUser
().
getUserName
()
self
.
assertEqual
(
auth_name
,
'Anonymous User'
)
self
.
assertEqual
(
auth_name
,
'Anonymous User'
)
self
.
assertEqual
(
self
.
_called
,
[
'beforeTearDown'
,
'beforeClose'
,
'afterClear'
])
self
.
assertEqual
(
self
.
_called
,
[
'beforeTearDown'
,
'beforeClose'
,
'afterClear'
])
...
@@ -339,7 +339,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -339,7 +339,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
self
.
_configure_portal
=
0
self
.
_configure_portal
=
0
self
.
_setUp
()
self
.
_setUp
()
self
.
assertEqual
(
self
.
portal
.
acl_users
.
getUserById
(
user_name
),
None
)
self
.
assertEqual
(
self
.
portal
.
acl_users
.
getUserById
(
user_name
),
None
)
self
.
failIf
(
hasattr_
(
self
.
portal
.
Members
,
user_name
))
self
.
assertFalse
(
hasattr_
(
self
.
portal
.
Members
,
user_name
))
auth_name
=
getSecurityManager
().
getUser
().
getUserName
()
auth_name
=
getSecurityManager
().
getUser
().
getUserName
()
self
.
assertEqual
(
auth_name
,
'Anonymous User'
)
self
.
assertEqual
(
auth_name
,
'Anonymous User'
)
# XXX: Changed in 0.9.0
# XXX: Changed in 0.9.0
...
@@ -355,7 +355,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -355,7 +355,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
self
.
login
()
self
.
login
()
self
.
createMemberarea
(
user_name
)
self
.
createMemberarea
(
user_name
)
self
.
assertEqual
(
self
.
portal
.
portal_membership
.
_called
,
[
'createMemberarea'
])
self
.
assertEqual
(
self
.
portal
.
portal_membership
.
_called
,
[
'createMemberarea'
])
self
.
failUnless
(
hasattr_
(
self
.
portal
.
Members
,
user_name
))
self
.
assertTrue
(
hasattr_
(
self
.
portal
.
Members
,
user_name
))
def
test_createMemberarea_NewTool
(
self
):
def
test_createMemberarea_NewTool
(
self
):
# Should call the membership tool's createMemberArea
# Should call the membership tool's createMemberArea
...
@@ -368,7 +368,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -368,7 +368,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
self
.
login
()
self
.
login
()
self
.
createMemberarea
(
user_name
)
self
.
createMemberarea
(
user_name
)
self
.
assertEqual
(
self
.
portal
.
portal_membership
.
_called
,
[
'createMemberArea'
])
self
.
assertEqual
(
self
.
portal
.
portal_membership
.
_called
,
[
'createMemberArea'
])
self
.
failUnless
(
hasattr_
(
self
.
portal
.
Members
,
user_name
))
self
.
assertTrue
(
hasattr_
(
self
.
portal
.
Members
,
user_name
))
# Helpers
# Helpers
...
@@ -422,16 +422,16 @@ class TestPlainUserFolder(ZopeTestCase.PortalTestCase):
...
@@ -422,16 +422,16 @@ class TestPlainUserFolder(ZopeTestCase.PortalTestCase):
def
testGetUserDoesNotWrapUser
(
self
):
def
testGetUserDoesNotWrapUser
(
self
):
user
=
self
.
portal
.
acl_users
.
getUserById
(
user_name
)
user
=
self
.
portal
.
acl_users
.
getUserById
(
user_name
)
self
.
failIf
(
hasattr
(
user
,
'aq_base'
))
self
.
assertFalse
(
hasattr
(
user
,
'aq_base'
))
self
.
failUnless
(
user
is
aq_base
(
user
))
self
.
assertTrue
(
user
is
aq_base
(
user
))
def
testLoggedInUserIsWrapped
(
self
):
def
testLoggedInUserIsWrapped
(
self
):
user
=
getSecurityManager
().
getUser
()
user
=
getSecurityManager
().
getUser
()
self
.
assertEqual
(
user
.
getId
(),
user_name
)
self
.
assertEqual
(
user
.
getId
(),
user_name
)
self
.
failUnless
(
hasattr
(
user
,
'aq_base'
))
self
.
assertTrue
(
hasattr
(
user
,
'aq_base'
))
self
.
failUnless
(
user
.
__class__
.
__name__
,
'User'
)
self
.
assertTrue
(
user
.
__class__
.
__name__
,
'User'
)
self
.
failUnless
(
user
.
aq_parent
.
__class__
.
__name__
,
'UserFolder'
)
self
.
assertTrue
(
user
.
aq_parent
.
__class__
.
__name__
,
'UserFolder'
)
self
.
failUnless
(
user
.
aq_parent
.
aq_parent
.
__class__
.
__name__
,
'Folder'
)
self
.
assertTrue
(
user
.
aq_parent
.
aq_parent
.
__class__
.
__name__
,
'Folder'
)
class
TestWrappingUserFolder
(
ZopeTestCase
.
PortalTestCase
):
class
TestWrappingUserFolder
(
ZopeTestCase
.
PortalTestCase
):
...
@@ -446,17 +446,17 @@ class TestWrappingUserFolder(ZopeTestCase.PortalTestCase):
...
@@ -446,17 +446,17 @@ class TestWrappingUserFolder(ZopeTestCase.PortalTestCase):
def
testGetUserWrapsUser
(
self
):
def
testGetUserWrapsUser
(
self
):
user
=
self
.
portal
.
acl_users
.
getUserById
(
user_name
)
user
=
self
.
portal
.
acl_users
.
getUserById
(
user_name
)
self
.
failUnless
(
hasattr
(
user
,
'aq_base'
))
self
.
assertTrue
(
hasattr
(
user
,
'aq_base'
))
self
.
failIf
(
user
is
aq_base
(
user
))
self
.
assertFalse
(
user
is
aq_base
(
user
))
self
.
failUnless
(
user
.
aq_parent
.
__class__
.
__name__
,
'WrappingUserFolder'
)
self
.
assertTrue
(
user
.
aq_parent
.
__class__
.
__name__
,
'WrappingUserFolder'
)
def
testLoggedInUserIsWrapped
(
self
):
def
testLoggedInUserIsWrapped
(
self
):
user
=
getSecurityManager
().
getUser
()
user
=
getSecurityManager
().
getUser
()
self
.
assertEqual
(
user
.
getId
(),
user_name
)
self
.
assertEqual
(
user
.
getId
(),
user_name
)
self
.
failUnless
(
hasattr
(
user
,
'aq_base'
))
self
.
assertTrue
(
hasattr
(
user
,
'aq_base'
))
self
.
failUnless
(
user
.
__class__
.
__name__
,
'User'
)
self
.
assertTrue
(
user
.
__class__
.
__name__
,
'User'
)
self
.
failUnless
(
user
.
aq_parent
.
__class__
.
__name__
,
'WrappingUserFolder'
)
self
.
assertTrue
(
user
.
aq_parent
.
__class__
.
__name__
,
'WrappingUserFolder'
)
self
.
failUnless
(
user
.
aq_parent
.
aq_parent
.
__class__
.
__name__
,
'Folder'
)
self
.
assertTrue
(
user
.
aq_parent
.
aq_parent
.
__class__
.
__name__
,
'Folder'
)
# Because we override setUp we need to test again
# Because we override setUp we need to test again
...
...
src/Testing/ZopeTestCase/testZODBCompat.py
View file @
6220f215
...
@@ -75,24 +75,24 @@ class TestCopyPaste(ZopeTestCase.ZopeTestCase):
...
@@ -75,24 +75,24 @@ class TestCopyPaste(ZopeTestCase.ZopeTestCase):
def
testCutPaste
(
self
):
def
testCutPaste
(
self
):
cb
=
self
.
folder
.
manage_cutObjects
([
'doc'
])
cb
=
self
.
folder
.
manage_cutObjects
([
'doc'
])
self
.
folder
.
manage_pasteObjects
(
cb
)
self
.
folder
.
manage_pasteObjects
(
cb
)
self
.
failUnless
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
failIf
(
hasattr
(
self
.
folder
,
'copy_of_doc'
))
self
.
assertFalse
(
hasattr
(
self
.
folder
,
'copy_of_doc'
))
def
testCopyPaste
(
self
):
def
testCopyPaste
(
self
):
cb
=
self
.
folder
.
manage_copyObjects
([
'doc'
])
cb
=
self
.
folder
.
manage_copyObjects
([
'doc'
])
self
.
folder
.
manage_pasteObjects
(
cb
)
self
.
folder
.
manage_pasteObjects
(
cb
)
self
.
failUnless
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
failUnless
(
hasattr
(
self
.
folder
,
'copy_of_doc'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'copy_of_doc'
))
def
testClone
(
self
):
def
testClone
(
self
):
self
.
folder
.
manage_clone
(
self
.
folder
.
doc
,
'new_doc'
)
self
.
folder
.
manage_clone
(
self
.
folder
.
doc
,
'new_doc'
)
self
.
failUnless
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
failUnless
(
hasattr
(
self
.
folder
,
'new_doc'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'new_doc'
))
def
testRename
(
self
):
def
testRename
(
self
):
self
.
folder
.
manage_renameObjects
([
'doc'
],
[
'new_doc'
])
self
.
folder
.
manage_renameObjects
([
'doc'
],
[
'new_doc'
])
self
.
failIf
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
assertFalse
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
failUnless
(
hasattr
(
self
.
folder
,
'new_doc'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'new_doc'
))
def
testCOPY
(
self
):
def
testCOPY
(
self
):
# WebDAV COPY
# WebDAV COPY
...
@@ -100,8 +100,8 @@ class TestCopyPaste(ZopeTestCase.ZopeTestCase):
...
@@ -100,8 +100,8 @@ class TestCopyPaste(ZopeTestCase.ZopeTestCase):
request
.
environ
[
'HTTP_DEPTH'
]
=
'infinity'
request
.
environ
[
'HTTP_DEPTH'
]
=
'infinity'
request
.
environ
[
'HTTP_DESTINATION'
]
=
'http://foo.com/%s/new_doc'
%
folder_name
request
.
environ
[
'HTTP_DESTINATION'
]
=
'http://foo.com/%s/new_doc'
%
folder_name
self
.
folder
.
doc
.
COPY
(
request
,
request
.
RESPONSE
)
self
.
folder
.
doc
.
COPY
(
request
,
request
.
RESPONSE
)
self
.
failUnless
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
failUnless
(
hasattr
(
self
.
folder
,
'new_doc'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'new_doc'
))
def
testMOVE
(
self
):
def
testMOVE
(
self
):
# WebDAV MOVE
# WebDAV MOVE
...
@@ -109,8 +109,8 @@ class TestCopyPaste(ZopeTestCase.ZopeTestCase):
...
@@ -109,8 +109,8 @@ class TestCopyPaste(ZopeTestCase.ZopeTestCase):
request
.
environ
[
'HTTP_DEPTH'
]
=
'infinity'
request
.
environ
[
'HTTP_DEPTH'
]
=
'infinity'
request
.
environ
[
'HTTP_DESTINATION'
]
=
'http://foo.com/%s/new_doc'
%
folder_name
request
.
environ
[
'HTTP_DESTINATION'
]
=
'http://foo.com/%s/new_doc'
%
folder_name
self
.
folder
.
doc
.
MOVE
(
request
,
request
.
RESPONSE
)
self
.
folder
.
doc
.
MOVE
(
request
,
request
.
RESPONSE
)
self
.
failIf
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
assertFalse
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
failUnless
(
hasattr
(
self
.
folder
,
'new_doc'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'new_doc'
))
class
TestImportExport
(
ZopeTestCase
.
ZopeTestCase
):
class
TestImportExport
(
ZopeTestCase
.
ZopeTestCase
):
...
@@ -125,13 +125,13 @@ class TestImportExport(ZopeTestCase.ZopeTestCase):
...
@@ -125,13 +125,13 @@ class TestImportExport(ZopeTestCase.ZopeTestCase):
def
testExport
(
self
):
def
testExport
(
self
):
self
.
folder
.
manage_exportObject
(
'doc'
)
self
.
folder
.
manage_exportObject
(
'doc'
)
self
.
failUnless
(
os
.
path
.
exists
(
self
.
zexp_file
))
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
zexp_file
))
def
testImport
(
self
):
def
testImport
(
self
):
self
.
folder
.
manage_exportObject
(
'doc'
)
self
.
folder
.
manage_exportObject
(
'doc'
)
self
.
folder
.
_delObject
(
'doc'
)
self
.
folder
.
_delObject
(
'doc'
)
self
.
folder
.
manage_importObject
(
'doc.zexp'
)
self
.
folder
.
manage_importObject
(
'doc.zexp'
)
self
.
failUnless
(
hasattr
(
self
.
folder
,
'doc'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'doc'
))
# To make export and import happy, we have to provide a file-
# To make export and import happy, we have to provide a file-
# system 'import' directory and adapt the configuration a bit:
# system 'import' directory and adapt the configuration a bit:
...
@@ -322,48 +322,48 @@ class TestTransactionAbort(ZopeTestCase.ZopeTestCase):
...
@@ -322,48 +322,48 @@ class TestTransactionAbort(ZopeTestCase.ZopeTestCase):
def
testTransactionAbort
(
self
):
def
testTransactionAbort
(
self
):
self
.
folder
.
foo
=
1
self
.
folder
.
foo
=
1
self
.
failUnless
(
hasattr
(
self
.
folder
,
'foo'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'foo'
))
transaction
.
abort
()
transaction
.
abort
()
# The foo attribute is still present
# The foo attribute is still present
self
.
failUnless
(
hasattr
(
self
.
folder
,
'foo'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'foo'
))
def
testSubTransactionAbort
(
self
):
def
testSubTransactionAbort
(
self
):
self
.
folder
.
foo
=
1
self
.
folder
.
foo
=
1
self
.
failUnless
(
hasattr
(
self
.
folder
,
'foo'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'foo'
))
transaction
.
savepoint
(
optimistic
=
True
)
transaction
.
savepoint
(
optimistic
=
True
)
transaction
.
abort
()
transaction
.
abort
()
# This time the abort nukes the foo attribute...
# This time the abort nukes the foo attribute...
self
.
failIf
(
hasattr
(
self
.
folder
,
'foo'
))
self
.
assertFalse
(
hasattr
(
self
.
folder
,
'foo'
))
def
testTransactionAbortPersistent
(
self
):
def
testTransactionAbortPersistent
(
self
):
self
.
folder
.
_p_foo
=
1
self
.
folder
.
_p_foo
=
1
self
.
failUnless
(
hasattr
(
self
.
folder
,
'_p_foo'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'_p_foo'
))
transaction
.
abort
()
transaction
.
abort
()
# The _p_foo attribute is still present
# The _p_foo attribute is still present
self
.
failUnless
(
hasattr
(
self
.
folder
,
'_p_foo'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'_p_foo'
))
def
testSubTransactionAbortPersistent
(
self
):
def
testSubTransactionAbortPersistent
(
self
):
self
.
folder
.
_p_foo
=
1
self
.
folder
.
_p_foo
=
1
self
.
failUnless
(
hasattr
(
self
.
folder
,
'_p_foo'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'_p_foo'
))
transaction
.
savepoint
(
optimistic
=
True
)
transaction
.
savepoint
(
optimistic
=
True
)
transaction
.
abort
()
transaction
.
abort
()
# This time the abort nukes the _p_foo attribute...
# This time the abort nukes the _p_foo attribute...
self
.
failIf
(
hasattr
(
self
.
folder
,
'_p_foo'
))
self
.
assertFalse
(
hasattr
(
self
.
folder
,
'_p_foo'
))
def
testTransactionAbortVolatile
(
self
):
def
testTransactionAbortVolatile
(
self
):
self
.
folder
.
_v_foo
=
1
self
.
folder
.
_v_foo
=
1
self
.
failUnless
(
hasattr
(
self
.
folder
,
'_v_foo'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'_v_foo'
))
transaction
.
abort
()
transaction
.
abort
()
# The _v_foo attribute is still present
# The _v_foo attribute is still present
self
.
failUnless
(
hasattr
(
self
.
folder
,
'_v_foo'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'_v_foo'
))
def
testSubTransactionAbortVolatile
(
self
):
def
testSubTransactionAbortVolatile
(
self
):
self
.
folder
.
_v_foo
=
1
self
.
folder
.
_v_foo
=
1
self
.
failUnless
(
hasattr
(
self
.
folder
,
'_v_foo'
))
self
.
assertTrue
(
hasattr
(
self
.
folder
,
'_v_foo'
))
transaction
.
savepoint
(
optimistic
=
True
)
transaction
.
savepoint
(
optimistic
=
True
)
transaction
.
abort
()
transaction
.
abort
()
# This time the abort nukes the _v_foo attribute...
# This time the abort nukes the _v_foo attribute...
self
.
failIf
(
hasattr
(
self
.
folder
,
'_v_foo'
))
self
.
assertFalse
(
hasattr
(
self
.
folder
,
'_v_foo'
))
def
test_suite
():
def
test_suite
():
...
...
src/Testing/ZopeTestCase/testZopeTestCase.py
View file @
6220f215
...
@@ -70,9 +70,9 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase):
...
@@ -70,9 +70,9 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase):
# Folder should be set up
# Folder should be set up
self
.
app
=
self
.
_app
()
self
.
app
=
self
.
_app
()
self
.
_setupFolder
()
self
.
_setupFolder
()
self
.
failUnless
(
hasattr_
(
self
.
app
,
folder_name
))
self
.
assertTrue
(
hasattr_
(
self
.
app
,
folder_name
))
self
.
failUnless
(
hasattr_
(
self
,
'folder'
))
self
.
assertTrue
(
hasattr_
(
self
,
'folder'
))
self
.
failUnless
(
user_role
in
self
.
folder
.
userdefined_roles
())
self
.
assertTrue
(
user_role
in
self
.
folder
.
userdefined_roles
())
self
.
assertPermissionsOfRole
(
standard_permissions
,
user_role
)
self
.
assertPermissionsOfRole
(
standard_permissions
,
user_role
)
def
test_setupUserFolder
(
self
):
def
test_setupUserFolder
(
self
):
...
@@ -80,7 +80,7 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase):
...
@@ -80,7 +80,7 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase):
self
.
app
=
self
.
_app
()
self
.
app
=
self
.
_app
()
self
.
_setupFolder
()
self
.
_setupFolder
()
self
.
_setupUserFolder
()
self
.
_setupUserFolder
()
self
.
failUnless
(
hasattr_
(
self
.
folder
,
'acl_users'
))
self
.
assertTrue
(
hasattr_
(
self
.
folder
,
'acl_users'
))
def
test_setupUser
(
self
):
def
test_setupUser
(
self
):
# User should be set up
# User should be set up
...
@@ -89,7 +89,7 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase):
...
@@ -89,7 +89,7 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase):
self
.
_setupUserFolder
()
self
.
_setupUserFolder
()
self
.
_setupUser
()
self
.
_setupUser
()
acl_user
=
self
.
folder
.
acl_users
.
getUserById
(
user_name
)
acl_user
=
self
.
folder
.
acl_users
.
getUserById
(
user_name
)
self
.
failUnless
(
acl_user
)
self
.
assertTrue
(
acl_user
)
self
.
assertEqual
(
acl_user
.
getRoles
(),
(
user_role
,
'Authenticated'
))
self
.
assertEqual
(
acl_user
.
getRoles
(),
(
user_role
,
'Authenticated'
))
self
.
assertEqual
(
type
(
acl_user
.
roles
),
ListType
)
self
.
assertEqual
(
type
(
acl_user
.
roles
),
ListType
)
...
@@ -235,7 +235,7 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase):
...
@@ -235,7 +235,7 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase):
self
.
_setupUser
()
self
.
_setupUser
()
self
.
login
()
self
.
login
()
self
.
_clear
(
1
)
self
.
_clear
(
1
)
self
.
failIf
(
self
.
app
.
__dict__
.
has_key
(
folder_name
))
self
.
assertFalse
(
self
.
app
.
__dict__
.
has_key
(
folder_name
))
auth_name
=
getSecurityManager
().
getUser
().
getUserName
()
auth_name
=
getSecurityManager
().
getUser
().
getUserName
()
self
.
assertEqual
(
auth_name
,
'Anonymous User'
)
self
.
assertEqual
(
auth_name
,
'Anonymous User'
)
self
.
assertEqual
(
self
.
_called
,
[
'beforeClose'
,
'afterClear'
])
self
.
assertEqual
(
self
.
_called
,
[
'beforeClose'
,
'afterClear'
])
...
@@ -245,13 +245,13 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase):
...
@@ -245,13 +245,13 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase):
def
test_setUp
(
self
):
def
test_setUp
(
self
):
# Everything should be set up
# Everything should be set up
self
.
_setUp
()
self
.
_setUp
()
self
.
failUnless
(
hasattr_
(
self
.
app
,
folder_name
))
self
.
assertTrue
(
hasattr_
(
self
.
app
,
folder_name
))
self
.
failUnless
(
hasattr_
(
self
,
'folder'
))
self
.
assertTrue
(
hasattr_
(
self
,
'folder'
))
self
.
failUnless
(
user_role
in
self
.
folder
.
userdefined_roles
())
self
.
assertTrue
(
user_role
in
self
.
folder
.
userdefined_roles
())
self
.
assertPermissionsOfRole
(
standard_permissions
,
user_role
)
self
.
assertPermissionsOfRole
(
standard_permissions
,
user_role
)
self
.
failUnless
(
hasattr_
(
self
.
folder
,
'acl_users'
))
self
.
assertTrue
(
hasattr_
(
self
.
folder
,
'acl_users'
))
acl_user
=
self
.
folder
.
acl_users
.
getUserById
(
user_name
)
acl_user
=
self
.
folder
.
acl_users
.
getUserById
(
user_name
)
self
.
failUnless
(
acl_user
)
self
.
assertTrue
(
acl_user
)
self
.
assertEqual
(
acl_user
.
getRoles
(),
(
user_role
,
'Authenticated'
))
self
.
assertEqual
(
acl_user
.
getRoles
(),
(
user_role
,
'Authenticated'
))
self
.
assertEqual
(
type
(
acl_user
.
roles
),
ListType
)
self
.
assertEqual
(
type
(
acl_user
.
roles
),
ListType
)
auth_name
=
getSecurityManager
().
getUser
().
getId
()
auth_name
=
getSecurityManager
().
getUser
().
getId
()
...
@@ -265,7 +265,7 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase):
...
@@ -265,7 +265,7 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase):
self
.
_setUp
()
self
.
_setUp
()
self
.
_called
=
[]
self
.
_called
=
[]
self
.
_tearDown
()
self
.
_tearDown
()
self
.
failIf
(
self
.
app
.
__dict__
.
has_key
(
folder_name
))
self
.
assertFalse
(
self
.
app
.
__dict__
.
has_key
(
folder_name
))
auth_name
=
getSecurityManager
().
getUser
().
getUserName
()
auth_name
=
getSecurityManager
().
getUser
().
getUserName
()
self
.
assertEqual
(
auth_name
,
'Anonymous User'
)
self
.
assertEqual
(
auth_name
,
'Anonymous User'
)
self
.
assertEqual
(
self
.
_called
,
[
'beforeTearDown'
,
'beforeClose'
,
'afterClear'
])
self
.
assertEqual
(
self
.
_called
,
[
'beforeTearDown'
,
'beforeClose'
,
'afterClear'
])
...
@@ -274,7 +274,7 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase):
...
@@ -274,7 +274,7 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase):
# Nothing should be set up
# Nothing should be set up
self
.
_setup_fixture
=
0
self
.
_setup_fixture
=
0
self
.
_setUp
()
self
.
_setUp
()
self
.
failIf
(
hasattr_
(
self
.
app
,
folder_name
))
self
.
assertFalse
(
hasattr_
(
self
.
app
,
folder_name
))
auth_name
=
getSecurityManager
().
getUser
().
getUserName
()
auth_name
=
getSecurityManager
().
getUser
().
getUserName
()
self
.
assertEqual
(
auth_name
,
'Anonymous User'
)
self
.
assertEqual
(
auth_name
,
'Anonymous User'
)
# XXX: Changed in 0.9.0
# XXX: Changed in 0.9.0
...
@@ -362,16 +362,16 @@ class TestPlainUserFolder(ZopeTestCase.ZopeTestCase):
...
@@ -362,16 +362,16 @@ class TestPlainUserFolder(ZopeTestCase.ZopeTestCase):
def
testGetUserDoesNotWrapUser
(
self
):
def
testGetUserDoesNotWrapUser
(
self
):
user
=
self
.
folder
.
acl_users
.
getUserById
(
user_name
)
user
=
self
.
folder
.
acl_users
.
getUserById
(
user_name
)
self
.
failIf
(
hasattr
(
user
,
'aq_base'
))
self
.
assertFalse
(
hasattr
(
user
,
'aq_base'
))
self
.
failUnless
(
user
is
aq_base
(
user
))
self
.
assertTrue
(
user
is
aq_base
(
user
))
def
testLoggedInUserIsWrapped
(
self
):
def
testLoggedInUserIsWrapped
(
self
):
user
=
getSecurityManager
().
getUser
()
user
=
getSecurityManager
().
getUser
()
self
.
assertEqual
(
user
.
getId
(),
user_name
)
self
.
assertEqual
(
user
.
getId
(),
user_name
)
self
.
failUnless
(
hasattr
(
user
,
'aq_base'
))
self
.
assertTrue
(
hasattr
(
user
,
'aq_base'
))
self
.
failUnless
(
user
.
__class__
.
__name__
,
'User'
)
self
.
assertTrue
(
user
.
__class__
.
__name__
,
'User'
)
self
.
failUnless
(
user
.
aq_parent
.
__class__
.
__name__
,
'UserFolder'
)
self
.
assertTrue
(
user
.
aq_parent
.
__class__
.
__name__
,
'UserFolder'
)
self
.
failUnless
(
user
.
aq_parent
.
aq_parent
.
__class__
.
__name__
,
'Folder'
)
self
.
assertTrue
(
user
.
aq_parent
.
aq_parent
.
__class__
.
__name__
,
'Folder'
)
class
TestWrappingUserFolder
(
ZopeTestCase
.
ZopeTestCase
):
class
TestWrappingUserFolder
(
ZopeTestCase
.
ZopeTestCase
):
...
@@ -382,17 +382,17 @@ class TestWrappingUserFolder(ZopeTestCase.ZopeTestCase):
...
@@ -382,17 +382,17 @@ class TestWrappingUserFolder(ZopeTestCase.ZopeTestCase):
def
testGetUserWrapsUser
(
self
):
def
testGetUserWrapsUser
(
self
):
user
=
self
.
folder
.
acl_users
.
getUserById
(
user_name
)
user
=
self
.
folder
.
acl_users
.
getUserById
(
user_name
)
self
.
failUnless
(
hasattr
(
user
,
'aq_base'
))
self
.
assertTrue
(
hasattr
(
user
,
'aq_base'
))
self
.
failIf
(
user
is
aq_base
(
user
))
self
.
assertFalse
(
user
is
aq_base
(
user
))
self
.
failUnless
(
user
.
aq_parent
.
__class__
.
__name__
,
'WrappingUserFolder'
)
self
.
assertTrue
(
user
.
aq_parent
.
__class__
.
__name__
,
'WrappingUserFolder'
)
def
testLoggedInUserIsWrapped
(
self
):
def
testLoggedInUserIsWrapped
(
self
):
user
=
getSecurityManager
().
getUser
()
user
=
getSecurityManager
().
getUser
()
self
.
assertEqual
(
user
.
getId
(),
user_name
)
self
.
assertEqual
(
user
.
getId
(),
user_name
)
self
.
failUnless
(
hasattr
(
user
,
'aq_base'
))
self
.
assertTrue
(
hasattr
(
user
,
'aq_base'
))
self
.
failUnless
(
user
.
__class__
.
__name__
,
'User'
)
self
.
assertTrue
(
user
.
__class__
.
__name__
,
'User'
)
self
.
failUnless
(
user
.
aq_parent
.
__class__
.
__name__
,
'WrappingUserFolder'
)
self
.
assertTrue
(
user
.
aq_parent
.
__class__
.
__name__
,
'WrappingUserFolder'
)
self
.
failUnless
(
user
.
aq_parent
.
aq_parent
.
__class__
.
__name__
,
'Folder'
)
self
.
assertTrue
(
user
.
aq_parent
.
aq_parent
.
__class__
.
__name__
,
'Folder'
)
def
test_suite
():
def
test_suite
():
...
...
src/Testing/tests/test_makerequest.py
View file @
6220f215
...
@@ -26,9 +26,9 @@ class MakerequestTests(unittest.TestCase):
...
@@ -26,9 +26,9 @@ class MakerequestTests(unittest.TestCase):
self
.
assertRaises
(
AttributeError
,
makerequest
,
object
())
self
.
assertRaises
(
AttributeError
,
makerequest
,
object
())
# After the call, it will have a REQUEST attribute.
# After the call, it will have a REQUEST attribute.
item
=
Implicit
()
item
=
Implicit
()
self
.
failIf
(
hasattr
(
item
,
'REQUEST'
))
self
.
assertFalse
(
hasattr
(
item
,
'REQUEST'
))
item
=
makerequest
(
item
)
item
=
makerequest
(
item
)
self
.
failUnless
(
hasattr
(
item
,
'REQUEST'
))
self
.
assertTrue
(
hasattr
(
item
,
'REQUEST'
))
def
test_dont_break_getPhysicalPath
(
self
):
def
test_dont_break_getPhysicalPath
(
self
):
# see http://www.zope.org/Collectors/Zope/2057. If you want
# see http://www.zope.org/Collectors/Zope/2057. If you want
...
@@ -49,8 +49,8 @@ class MakerequestTests(unittest.TestCase):
...
@@ -49,8 +49,8 @@ class MakerequestTests(unittest.TestCase):
item
.
REQUEST
.
RESPONSE
.
write
(
'aaa'
)
item
.
REQUEST
.
RESPONSE
.
write
(
'aaa'
)
out
.
seek
(
0
)
out
.
seek
(
0
)
written
=
out
.
read
()
written
=
out
.
read
()
self
.
failUnless
(
written
.
startswith
(
'Status: 200 OK
\
r
\
n
'
))
self
.
assertTrue
(
written
.
startswith
(
'Status: 200 OK
\
r
\
n
'
))
self
.
failUnless
(
written
.
endswith
(
'
\
n
aaa'
))
self
.
assertTrue
(
written
.
endswith
(
'
\
n
aaa'
))
def
test_environ
(
self
):
def
test_environ
(
self
):
# You can pass an environ argument to use in the request.
# You can pass an environ argument to use in the request.
...
...
src/ZPublisher/tests/testHTTPRangeSupport.py
View file @
6220f215
...
@@ -21,11 +21,11 @@ class TestRangeHeaderParse(unittest.TestCase):
...
@@ -21,11 +21,11 @@ class TestRangeHeaderParse(unittest.TestCase):
# Utility methods
# Utility methods
def
expectNone
(
self
,
header
):
def
expectNone
(
self
,
header
):
result
=
parseRange
(
header
)
result
=
parseRange
(
header
)
self
.
failUnless
(
result
is
None
,
'Expected None, got %s'
%
`result`
)
self
.
assertTrue
(
result
is
None
,
'Expected None, got %s'
%
`result`
)
def
expectSets
(
self
,
header
,
sets
):
def
expectSets
(
self
,
header
,
sets
):
result
=
parseRange
(
header
)
result
=
parseRange
(
header
)
self
.
failUnless
(
result
==
sets
,
self
.
assertTrue
(
result
==
sets
,
'Expected %s, got %s'
%
(
`sets`
,
`result`
))
'Expected %s, got %s'
%
(
`sets`
,
`result`
))
# Syntactically incorrect headers
# Syntactically incorrect headers
...
@@ -81,7 +81,7 @@ class TestExpandRanges(unittest.TestCase):
...
@@ -81,7 +81,7 @@ class TestExpandRanges(unittest.TestCase):
def
expectSets
(
self
,
sets
,
size
,
expect
):
def
expectSets
(
self
,
sets
,
size
,
expect
):
result
=
expandRanges
(
sets
,
size
)
result
=
expandRanges
(
sets
,
size
)
self
.
failUnless
(
result
==
expect
,
self
.
assertTrue
(
result
==
expect
,
'Expected %s, got %s'
%
(
`expect`
,
`result`
))
'Expected %s, got %s'
%
(
`expect`
,
`result`
))
def
testExpandOpenEnd
(
self
):
def
testExpandOpenEnd
(
self
):
...
...
src/ZPublisher/tests/testHTTPRequest.py
View file @
6220f215
...
@@ -72,7 +72,7 @@ class HTTPRequestTests(unittest.TestCase):
...
@@ -72,7 +72,7 @@ class HTTPRequestTests(unittest.TestCase):
return
req
return
req
def
_noTaintedValues
(
self
,
req
):
def
_noTaintedValues
(
self
,
req
):
self
.
failIf
(
req
.
taintedform
.
keys
())
self
.
assertFalse
(
req
.
taintedform
.
keys
())
def
_valueIsOrHoldsTainted
(
self
,
val
):
def
_valueIsOrHoldsTainted
(
self
,
val
):
# Recursively searches a structure for a TaintedString and returns 1
# Recursively searches a structure for a TaintedString and returns 1
...
@@ -85,7 +85,7 @@ class HTTPRequestTests(unittest.TestCase):
...
@@ -85,7 +85,7 @@ class HTTPRequestTests(unittest.TestCase):
retval
=
0
retval
=
0
if
isinstance
(
val
,
TaintedString
):
if
isinstance
(
val
,
TaintedString
):
self
.
failIf
(
not
'<'
in
val
,
self
.
assertFalse
(
not
'<'
in
val
,
"%r is not dangerous, no taint required."
%
val
)
"%r is not dangerous, no taint required."
%
val
)
retval
=
1
retval
=
1
...
@@ -102,18 +102,18 @@ class HTTPRequestTests(unittest.TestCase):
...
@@ -102,18 +102,18 @@ class HTTPRequestTests(unittest.TestCase):
if
rval
:
retval
=
1
if
rval
:
retval
=
1
elif
type
(
val
)
in
(
str
,
unicode
):
elif
type
(
val
)
in
(
str
,
unicode
):
self
.
failIf
(
'<'
in
val
,
self
.
assertFalse
(
'<'
in
val
,
"'%s' is dangerous and should have been tainted."
%
val
)
"'%s' is dangerous and should have been tainted."
%
val
)
return
retval
return
retval
def
_noFormValuesInOther
(
self
,
req
):
def
_noFormValuesInOther
(
self
,
req
):
for
key
in
req
.
taintedform
.
keys
():
for
key
in
req
.
taintedform
.
keys
():
self
.
failIf
(
req
.
other
.
has_key
(
key
),
self
.
assertFalse
(
req
.
other
.
has_key
(
key
),
'REQUEST.other should not hold tainted values at first!'
)
'REQUEST.other should not hold tainted values at first!'
)
for
key
in
req
.
form
.
keys
():
for
key
in
req
.
form
.
keys
():
self
.
failIf
(
req
.
other
.
has_key
(
key
),
self
.
assertFalse
(
req
.
other
.
has_key
(
key
),
'REQUEST.other should not hold form values at first!'
)
'REQUEST.other should not hold form values at first!'
)
def
_onlyTaintedformHoldsTaintedStrings
(
self
,
req
):
def
_onlyTaintedformHoldsTaintedStrings
(
self
,
req
):
...
@@ -125,7 +125,7 @@ class HTTPRequestTests(unittest.TestCase):
...
@@ -125,7 +125,7 @@ class HTTPRequestTests(unittest.TestCase):
for
key
,
val
in
req
.
form
.
items
():
for
key
,
val
in
req
.
form
.
items
():
if
req
.
taintedform
.
has_key
(
key
):
if
req
.
taintedform
.
has_key
(
key
):
continue
continue
self
.
failIf
(
self
.
_valueIsOrHoldsTainted
(
key
)
or
self
.
assertFalse
(
self
.
_valueIsOrHoldsTainted
(
key
)
or
self
.
_valueIsOrHoldsTainted
(
val
),
self
.
_valueIsOrHoldsTainted
(
val
),
'Normal form holds item %s that is tainted'
%
key
)
'Normal form holds item %s that is tainted'
%
key
)
...
@@ -579,10 +579,10 @@ class HTTPRequestTests(unittest.TestCase):
...
@@ -579,10 +579,10 @@ class HTTPRequestTests(unittest.TestCase):
try
:
try
:
convert
(
'<html garbage>'
)
convert
(
'<html garbage>'
)
except
Exception
,
e
:
except
Exception
,
e
:
self
.
failIf
(
'<'
in
e
.
args
,
self
.
assertFalse
(
'<'
in
e
.
args
,
'%s converter does not quote unsafe value!'
%
type
)
'%s converter does not quote unsafe value!'
%
type
)
except
DateTime
.
SyntaxError
,
e
:
except
DateTime
.
SyntaxError
,
e
:
self
.
failIf
(
'<'
in
e
,
self
.
assertFalse
(
'<'
in
e
,
'%s converter does not quote unsafe value!'
%
type
)
'%s converter does not quote unsafe value!'
%
type
)
def
test_processInputs_w_dotted_name_as_tuple
(
self
):
def
test_processInputs_w_dotted_name_as_tuple
(
self
):
...
@@ -977,7 +977,7 @@ class HTTPRequestTests(unittest.TestCase):
...
@@ -977,7 +977,7 @@ class HTTPRequestTests(unittest.TestCase):
request
=
self
.
_makeOne
(
None
,
TEST_ENVIRON
.
copy
(),
DummyResponse
())
request
=
self
.
_makeOne
(
None
,
TEST_ENVIRON
.
copy
(),
DummyResponse
())
request
[
'PARENTS'
]
=
[
object
()]
request
[
'PARENTS'
]
=
[
object
()]
clone
=
request
.
clone
()
clone
=
request
.
clone
()
self
.
failUnless
(
isinstance
(
clone
.
response
,
DummyResponse
))
self
.
assertTrue
(
isinstance
(
clone
.
response
,
DummyResponse
))
def
test_clone_preserves_request_subclass
(
self
):
def
test_clone_preserves_request_subclass
(
self
):
class
SubRequest
(
self
.
_getTargetClass
()):
class
SubRequest
(
self
.
_getTargetClass
()):
...
@@ -985,7 +985,7 @@ class HTTPRequestTests(unittest.TestCase):
...
@@ -985,7 +985,7 @@ class HTTPRequestTests(unittest.TestCase):
request
=
SubRequest
(
None
,
TEST_ENVIRON
.
copy
(),
None
)
request
=
SubRequest
(
None
,
TEST_ENVIRON
.
copy
(),
None
)
request
[
'PARENTS'
]
=
[
object
()]
request
[
'PARENTS'
]
=
[
object
()]
clone
=
request
.
clone
()
clone
=
request
.
clone
()
self
.
failUnless
(
isinstance
(
clone
,
SubRequest
))
self
.
assertTrue
(
isinstance
(
clone
,
SubRequest
))
def
test_clone_preserves_direct_interfaces
(
self
):
def
test_clone_preserves_direct_interfaces
(
self
):
from
zope.interface
import
directlyProvides
from
zope.interface
import
directlyProvides
...
@@ -996,7 +996,7 @@ class HTTPRequestTests(unittest.TestCase):
...
@@ -996,7 +996,7 @@ class HTTPRequestTests(unittest.TestCase):
request
[
'PARENTS'
]
=
[
object
()]
request
[
'PARENTS'
]
=
[
object
()]
directlyProvides
(
request
,
IFoo
)
directlyProvides
(
request
,
IFoo
)
clone
=
request
.
clone
()
clone
=
request
.
clone
()
self
.
failUnless
(
IFoo
.
providedBy
(
clone
))
self
.
assertTrue
(
IFoo
.
providedBy
(
clone
))
def
test_resolve_url_doesnt_send_endrequestevent
(
self
):
def
test_resolve_url_doesnt_send_endrequestevent
(
self
):
import
zope.event
import
zope.event
...
@@ -1008,7 +1008,7 @@ class HTTPRequestTests(unittest.TestCase):
...
@@ -1008,7 +1008,7 @@ class HTTPRequestTests(unittest.TestCase):
request
.
resolve_url
(
request
.
script
+
'/'
)
request
.
resolve_url
(
request
.
script
+
'/'
)
finally
:
finally
:
zope
.
event
.
subscribers
.
remove
(
events
.
append
)
zope
.
event
.
subscribers
.
remove
(
events
.
append
)
self
.
failIf
(
len
(
events
),
self
.
assertFalse
(
len
(
events
),
"HTTPRequest.resolve_url should not emit events"
)
"HTTPRequest.resolve_url should not emit events"
)
def
test_resolve_url_errorhandling
(
self
):
def
test_resolve_url_errorhandling
(
self
):
...
...
src/ZPublisher/tests/testHTTPResponse.py
View file @
6220f215
This diff is collapsed.
Click to expand it.
src/ZPublisher/tests/test_WSGIPublisher.py
View file @
6220f215
...
@@ -53,7 +53,7 @@ class WSGIResponseTests(unittest.TestCase):
...
@@ -53,7 +53,7 @@ class WSGIResponseTests(unittest.TestCase):
response
.
_streaming
=
True
response
.
_streaming
=
True
response
.
body
=
'TESTING'
response
.
body
=
'TESTING'
response
.
finalize
()
response
.
finalize
()
self
.
failIf
(
response
.
getHeader
(
'Content-Length'
))
self
.
assertFalse
(
response
.
getHeader
(
'Content-Length'
))
def
test_finalize_HTTP_1_0_keep_alive_w_content_length
(
self
):
def
test_finalize_HTTP_1_0_keep_alive_w_content_length
(
self
):
response
=
self
.
_makeOne
()
response
=
self
.
_makeOne
()
...
@@ -93,7 +93,7 @@ class WSGIResponseTests(unittest.TestCase):
...
@@ -93,7 +93,7 @@ class WSGIResponseTests(unittest.TestCase):
response
.
finalize
()
response
.
finalize
()
self
.
assertEqual
(
response
.
getHeader
(
'Connection'
),
'close'
)
self
.
assertEqual
(
response
.
getHeader
(
'Connection'
),
'close'
)
self
.
assertEqual
(
response
.
getHeader
(
'Transfer-Encoding'
),
None
)
self
.
assertEqual
(
response
.
getHeader
(
'Transfer-Encoding'
),
None
)
self
.
failIf
(
response
.
_chunking
)
self
.
assertFalse
(
response
.
_chunking
)
def
test_finalize_HTTP_1_1_wo_content_length_streaming_w_http_chunk
(
self
):
def
test_finalize_HTTP_1_1_wo_content_length_streaming_w_http_chunk
(
self
):
response
=
self
.
_makeOne
()
response
=
self
.
_makeOne
()
...
@@ -115,7 +115,7 @@ class WSGIResponseTests(unittest.TestCase):
...
@@ -115,7 +115,7 @@ class WSGIResponseTests(unittest.TestCase):
response
.
setBody
(
'TESTING'
)
response
.
setBody
(
'TESTING'
)
headers
=
response
.
listHeaders
()
headers
=
response
.
listHeaders
()
sv
=
[
x
for
x
in
headers
if
x
[
0
]
==
'Server'
]
sv
=
[
x
for
x
in
headers
if
x
[
0
]
==
'Server'
]
self
.
failIf
(
sv
)
self
.
assertFalse
(
sv
)
def
test_listHeaders_includes_Server_header_w_server_version_set
(
self
):
def
test_listHeaders_includes_Server_header_w_server_version_set
(
self
):
response
=
self
.
_makeOne
()
response
=
self
.
_makeOne
()
...
@@ -123,7 +123,7 @@ class WSGIResponseTests(unittest.TestCase):
...
@@ -123,7 +123,7 @@ class WSGIResponseTests(unittest.TestCase):
response
.
setBody
(
'TESTING'
)
response
.
setBody
(
'TESTING'
)
headers
=
response
.
listHeaders
()
headers
=
response
.
listHeaders
()
sv
=
[
x
for
x
in
headers
if
x
[
0
]
==
'Server'
]
sv
=
[
x
for
x
in
headers
if
x
[
0
]
==
'Server'
]
self
.
failUnless
((
'Server'
,
'TESTME'
)
in
sv
)
self
.
assertTrue
((
'Server'
,
'TESTME'
)
in
sv
)
def
test_listHeaders_includes_Date_header
(
self
):
def
test_listHeaders_includes_Date_header
(
self
):
import
time
import
time
...
@@ -134,7 +134,7 @@ class WSGIResponseTests(unittest.TestCase):
...
@@ -134,7 +134,7 @@ class WSGIResponseTests(unittest.TestCase):
headers
=
response
.
listHeaders
()
headers
=
response
.
listHeaders
()
whenstr
=
time
.
strftime
(
'%a, %d %b %Y %H:%M:%S GMT'
,
whenstr
=
time
.
strftime
(
'%a, %d %b %Y %H:%M:%S GMT'
,
time
.
gmtime
(
time
.
mktime
(
WHEN
)))
time
.
gmtime
(
time
.
mktime
(
WHEN
)))
self
.
failUnless
((
'Date'
,
whenstr
)
in
headers
)
self
.
assertTrue
((
'Date'
,
whenstr
)
in
headers
)
#def test___str__already_wrote_not_chunking(self):
#def test___str__already_wrote_not_chunking(self):
# response = self._makeOne()
# response = self._makeOne()
...
@@ -186,11 +186,11 @@ class Test_publish(unittest.TestCase):
...
@@ -186,11 +186,11 @@ class Test_publish(unittest.TestCase):
_gmi
.
_result
=
(
_before
,
_after
,
_object
,
_realm
,
_debug_mode
,
_gmi
.
_result
=
(
_before
,
_after
,
_object
,
_realm
,
_debug_mode
,
_err_hook
,
_validated_hook
,
_tm
)
_err_hook
,
_validated_hook
,
_tm
)
returned
=
self
.
_callFUT
(
request
,
'okmodule'
,
_gmi
)
returned
=
self
.
_callFUT
(
request
,
'okmodule'
,
_gmi
)
self
.
failUnless
(
returned
is
response
)
self
.
assertTrue
(
returned
is
response
)
self
.
assertEqual
(
_gmi
.
_called_with
,
((
'okmodule'
,),
{}))
self
.
assertEqual
(
_gmi
.
_called_with
,
((
'okmodule'
,),
{}))
self
.
failUnless
(
request
.
_processedInputs
)
self
.
assertTrue
(
request
.
_processedInputs
)
self
.
assertEqual
(
response
.
after_list
,
(
_after
,))
self
.
assertEqual
(
response
.
after_list
,
(
_after
,))
self
.
failUnless
(
response
.
debug_mode
)
self
.
assertTrue
(
response
.
debug_mode
)
self
.
assertEqual
(
response
.
realm
,
'TESTING'
)
self
.
assertEqual
(
response
.
realm
,
'TESTING'
)
self
.
assertEqual
(
_before
.
_called_with
,
((),
{}))
self
.
assertEqual
(
_before
.
_called_with
,
((),
{}))
self
.
assertEqual
(
request
[
'PARENTS'
],
[
_object
])
self
.
assertEqual
(
request
[
'PARENTS'
],
[
_object
])
...
@@ -319,10 +319,10 @@ class Test_publish_module(unittest.TestCase):
...
@@ -319,10 +319,10 @@ class Test_publish_module(unittest.TestCase):
self
.
assertEqual
(
headers
,
[(
'Content-Length'
,
'0'
)])
self
.
assertEqual
(
headers
,
[(
'Content-Length'
,
'0'
)])
self
.
assertEqual
(
kw
,
{})
self
.
assertEqual
(
kw
,
{})
(
request
,
module
),
kw
=
_publish
.
_called_with
(
request
,
module
),
kw
=
_publish
.
_called_with
self
.
failUnless
(
isinstance
(
request
,
HTTPRequest
))
self
.
assertTrue
(
isinstance
(
request
,
HTTPRequest
))
self
.
assertEqual
(
module
,
'Zope2'
)
self
.
assertEqual
(
module
,
'Zope2'
)
self
.
assertEqual
(
kw
,
{})
self
.
assertEqual
(
kw
,
{})
self
.
failUnless
(
_response
.
_finalized
)
self
.
assertTrue
(
_response
.
_finalized
)
self
.
assertEqual
(
_after1
.
_called_with
,
((),
{}))
self
.
assertEqual
(
_after1
.
_called_with
,
((),
{}))
self
.
assertEqual
(
_after2
.
_called_with
,
((),
{}))
self
.
assertEqual
(
_after2
.
_called_with
,
((),
{}))
...
@@ -336,7 +336,7 @@ class Test_publish_module(unittest.TestCase):
...
@@ -336,7 +336,7 @@ class Test_publish_module(unittest.TestCase):
self
.
assertEqual
(
app_iter
,
(
''
,
''
))
self
.
assertEqual
(
app_iter
,
(
''
,
''
))
(
status
,
headers
),
kw
=
start_response
.
_called_with
(
status
,
headers
),
kw
=
start_response
.
_called_with
self
.
assertEqual
(
status
,
'401 Unauthorized'
)
self
.
assertEqual
(
status
,
'401 Unauthorized'
)
self
.
failUnless
((
'Content-Length'
,
'0'
)
in
headers
)
self
.
assertTrue
((
'Content-Length'
,
'0'
)
in
headers
)
self
.
assertEqual
(
kw
,
{})
self
.
assertEqual
(
kw
,
{})
def
test_swallows_Redirect
(
self
):
def
test_swallows_Redirect
(
self
):
...
@@ -349,8 +349,8 @@ class Test_publish_module(unittest.TestCase):
...
@@ -349,8 +349,8 @@ class Test_publish_module(unittest.TestCase):
self
.
assertEqual
(
app_iter
,
(
''
,
''
))
self
.
assertEqual
(
app_iter
,
(
''
,
''
))
(
status
,
headers
),
kw
=
start_response
.
_called_with
(
status
,
headers
),
kw
=
start_response
.
_called_with
self
.
assertEqual
(
status
,
'302 Moved Temporarily'
)
self
.
assertEqual
(
status
,
'302 Moved Temporarily'
)
self
.
failUnless
((
'Location'
,
'/redirect_to'
)
in
headers
)
self
.
assertTrue
((
'Location'
,
'/redirect_to'
)
in
headers
)
self
.
failUnless
((
'Content-Length'
,
'0'
)
in
headers
)
self
.
assertTrue
((
'Content-Length'
,
'0'
)
in
headers
)
self
.
assertEqual
(
kw
,
{})
self
.
assertEqual
(
kw
,
{})
def
test_response_body_is_file
(
self
):
def
test_response_body_is_file
(
self
):
...
@@ -368,7 +368,7 @@ class Test_publish_module(unittest.TestCase):
...
@@ -368,7 +368,7 @@ class Test_publish_module(unittest.TestCase):
_publish
=
DummyCallable
()
_publish
=
DummyCallable
()
_publish
.
_result
=
_response
_publish
.
_result
=
_response
app_iter
=
self
.
_callFUT
(
environ
,
start_response
,
_publish
)
app_iter
=
self
.
_callFUT
(
environ
,
start_response
,
_publish
)
self
.
failUnless
(
app_iter
is
body
)
self
.
assertTrue
(
app_iter
is
body
)
def
test_request_closed_when_tm_middleware_not_active
(
self
):
def
test_request_closed_when_tm_middleware_not_active
(
self
):
environ
=
self
.
_makeEnviron
()
environ
=
self
.
_makeEnviron
()
...
@@ -384,7 +384,7 @@ class Test_publish_module(unittest.TestCase):
...
@@ -384,7 +384,7 @@ class Test_publish_module(unittest.TestCase):
_publish
.
_result
=
DummyResponse
()
_publish
.
_result
=
DummyResponse
()
app_iter
=
self
.
_callFUT
(
environ
,
start_response
,
_publish
,
app_iter
=
self
.
_callFUT
(
environ
,
start_response
,
_publish
,
_request_factory
=
_request_factory
)
_request_factory
=
_request_factory
)
self
.
failUnless
(
_request
.
_closed
)
self
.
assertTrue
(
_request
.
_closed
)
def
test_request_not_closed_when_tm_middleware_active
(
self
):
def
test_request_not_closed_when_tm_middleware_active
(
self
):
import
transaction
import
transaction
...
@@ -402,9 +402,9 @@ class Test_publish_module(unittest.TestCase):
...
@@ -402,9 +402,9 @@ class Test_publish_module(unittest.TestCase):
_publish
.
_result
=
DummyResponse
()
_publish
.
_result
=
DummyResponse
()
app_iter
=
self
.
_callFUT
(
environ
,
start_response
,
_publish
,
app_iter
=
self
.
_callFUT
(
environ
,
start_response
,
_publish
,
_request_factory
=
_request_factory
)
_request_factory
=
_request_factory
)
self
.
failIf
(
_request
.
_closed
)
self
.
assertFalse
(
_request
.
_closed
)
txn
=
transaction
.
get
()
txn
=
transaction
.
get
()
self
.
failUnless
(
list
(
txn
.
getAfterCommitHooks
()))
self
.
assertTrue
(
list
(
txn
.
getAfterCommitHooks
()))
class
DummyRequest
(
dict
):
class
DummyRequest
(
dict
):
...
...
src/ZPublisher/tests/test_xmlrpc.py
View file @
6220f215
...
@@ -46,8 +46,8 @@ class XMLRPCResponseTests(unittest.TestCase):
...
@@ -46,8 +46,8 @@ class XMLRPCResponseTests(unittest.TestCase):
as_set
=
as_set
[
0
]
as_set
=
as_set
[
0
]
self
.
assertEqual
(
method
,
None
)
self
.
assertEqual
(
method
,
None
)
self
.
failIf
(
'_secret'
in
as_set
.
keys
())
self
.
assertFalse
(
'_secret'
in
as_set
.
keys
())
self
.
failUnless
(
'public'
in
as_set
.
keys
())
self
.
assertTrue
(
'public'
in
as_set
.
keys
())
self
.
assertEqual
(
as_set
[
'public'
],
'def'
)
self
.
assertEqual
(
as_set
[
'public'
],
'def'
)
def
test_nil
(
self
):
def
test_nil
(
self
):
...
@@ -130,7 +130,7 @@ class XMLRPCResponseTests(unittest.TestCase):
...
@@ -130,7 +130,7 @@ class XMLRPCResponseTests(unittest.TestCase):
response
.
setBody
(
body
)
response
.
setBody
(
body
)
data
,
method
=
xmlrpclib
.
loads
(
faux
.
_body
)
data
,
method
=
xmlrpclib
.
loads
(
faux
.
_body
)
data
=
data
[
0
]
data
=
data
[
0
]
self
.
failUnless
(
isinstance
(
data
,
xmlrpclib
.
DateTime
))
self
.
assertTrue
(
isinstance
(
data
,
xmlrpclib
.
DateTime
))
self
.
assertEqual
(
data
.
value
,
u'2006-05-24T07:00:00+00:00'
)
self
.
assertEqual
(
data
.
value
,
u'2006-05-24T07:00:00+00:00'
)
def
test_zopedatetimeattribute
(
self
):
def
test_zopedatetimeattribute
(
self
):
...
@@ -142,7 +142,7 @@ class XMLRPCResponseTests(unittest.TestCase):
...
@@ -142,7 +142,7 @@ class XMLRPCResponseTests(unittest.TestCase):
response
.
setBody
(
body
)
response
.
setBody
(
body
)
data
,
method
=
xmlrpclib
.
loads
(
faux
.
_body
)
data
,
method
=
xmlrpclib
.
loads
(
faux
.
_body
)
data
=
data
[
0
][
'public'
]
data
=
data
[
0
][
'public'
]
self
.
failUnless
(
isinstance
(
data
,
xmlrpclib
.
DateTime
))
self
.
assertTrue
(
isinstance
(
data
,
xmlrpclib
.
DateTime
))
self
.
assertEqual
(
data
.
value
,
u'2006-05-24T07:00:00+00:00'
)
self
.
assertEqual
(
data
.
value
,
u'2006-05-24T07:00:00+00:00'
)
def
test_zopedatetimeattribute_recursive
(
self
):
def
test_zopedatetimeattribute_recursive
(
self
):
...
@@ -154,7 +154,7 @@ class XMLRPCResponseTests(unittest.TestCase):
...
@@ -154,7 +154,7 @@ class XMLRPCResponseTests(unittest.TestCase):
response
.
setBody
(
body
)
response
.
setBody
(
body
)
data
,
method
=
xmlrpclib
.
loads
(
faux
.
_body
)
data
,
method
=
xmlrpclib
.
loads
(
faux
.
_body
)
data
=
data
[
0
][
'public'
][
'public'
]
data
=
data
[
0
][
'public'
][
'public'
]
self
.
failUnless
(
isinstance
(
data
,
xmlrpclib
.
DateTime
))
self
.
assertTrue
(
isinstance
(
data
,
xmlrpclib
.
DateTime
))
self
.
assertEqual
(
data
.
value
,
u'2006-05-24T07:00:00+00:00'
)
self
.
assertEqual
(
data
.
value
,
u'2006-05-24T07:00:00+00:00'
)
def
test_zopedatetimeinstance_in_list
(
self
):
def
test_zopedatetimeinstance_in_list
(
self
):
...
@@ -166,7 +166,7 @@ class XMLRPCResponseTests(unittest.TestCase):
...
@@ -166,7 +166,7 @@ class XMLRPCResponseTests(unittest.TestCase):
response
.
setBody
(
body
)
response
.
setBody
(
body
)
data
,
method
=
xmlrpclib
.
loads
(
faux
.
_body
)
data
,
method
=
xmlrpclib
.
loads
(
faux
.
_body
)
data
=
data
[
0
][
0
]
data
=
data
[
0
][
0
]
self
.
failUnless
(
isinstance
(
data
,
xmlrpclib
.
DateTime
))
self
.
assertTrue
(
isinstance
(
data
,
xmlrpclib
.
DateTime
))
self
.
assertEqual
(
data
.
value
,
u'2006-05-24T07:00:00+00:00'
)
self
.
assertEqual
(
data
.
value
,
u'2006-05-24T07:00:00+00:00'
)
def
test_zopedatetimeinstance_in_dict
(
self
):
def
test_zopedatetimeinstance_in_dict
(
self
):
...
@@ -178,7 +178,7 @@ class XMLRPCResponseTests(unittest.TestCase):
...
@@ -178,7 +178,7 @@ class XMLRPCResponseTests(unittest.TestCase):
response
.
setBody
(
body
)
response
.
setBody
(
body
)
data
,
method
=
xmlrpclib
.
loads
(
faux
.
_body
)
data
,
method
=
xmlrpclib
.
loads
(
faux
.
_body
)
data
=
data
[
0
][
'date'
]
data
=
data
[
0
][
'date'
]
self
.
failUnless
(
isinstance
(
data
,
xmlrpclib
.
DateTime
))
self
.
assertTrue
(
isinstance
(
data
,
xmlrpclib
.
DateTime
))
self
.
assertEqual
(
data
.
value
,
u'2006-05-24T07:00:00+00:00'
)
self
.
assertEqual
(
data
.
value
,
u'2006-05-24T07:00:00+00:00'
)
def
test_functionattribute
(
self
):
def
test_functionattribute
(
self
):
...
...
src/ZPublisher/tests/testpubevents.py
View file @
6220f215
...
@@ -146,7 +146,7 @@ class TestPubEvents(TestCase):
...
@@ -146,7 +146,7 @@ class TestPubEvents(TestCase):
self
.
assert_
(
isinstance
(
events
[
0
],
PubBeforeStreaming
))
self
.
assert_
(
isinstance
(
events
[
0
],
PubBeforeStreaming
))
self
.
assertEqual
(
events
[
0
].
response
,
response
)
self
.
assertEqual
(
events
[
0
].
response
,
response
)
self
.
failUnless
(
'datachunk1datachunk2'
in
out
.
getvalue
())
self
.
assertTrue
(
'datachunk1datachunk2'
in
out
.
getvalue
())
# Auxiliaries
# Auxiliaries
...
...
src/ZServer/tests/test_clockserver.py
View file @
6220f215
...
@@ -59,9 +59,9 @@ class ClockServerTests(unittest.TestCase):
...
@@ -59,9 +59,9 @@ class ClockServerTests(unittest.TestCase):
from
ZServer.medusa.http_server
import
http_request
from
ZServer.medusa.http_server
import
http_request
from
ZServer.HTTPResponse
import
HTTPResponse
from
ZServer.HTTPResponse
import
HTTPResponse
from
ZPublisher.HTTPRequest
import
HTTPRequest
from
ZPublisher.HTTPRequest
import
HTTPRequest
self
.
failUnless
(
isinstance
(
req
,
http_request
))
self
.
assertTrue
(
isinstance
(
req
,
http_request
))
self
.
failUnless
(
isinstance
(
resp
,
HTTPResponse
))
self
.
assertTrue
(
isinstance
(
resp
,
HTTPResponse
))
self
.
failUnless
(
isinstance
(
zreq
,
HTTPRequest
))
self
.
assertTrue
(
isinstance
(
zreq
,
HTTPRequest
))
def
test_get_env
(
self
):
def
test_get_env
(
self
):
logger
=
DummyLogger
()
logger
=
DummyLogger
()
...
...
src/ZServer/tests/test_responses.py
View file @
6220f215
...
@@ -304,7 +304,7 @@ class ZServerHTTPResponseEventsTestCase(unittest.TestCase):
...
@@ -304,7 +304,7 @@ class ZServerHTTPResponseEventsTestCase(unittest.TestCase):
self
.
assert_
(
isinstance
(
events
[
0
],
PubBeforeStreaming
))
self
.
assert_
(
isinstance
(
events
[
0
],
PubBeforeStreaming
))
self
.
assertEqual
(
events
[
0
].
response
,
response
)
self
.
assertEqual
(
events
[
0
].
response
,
response
)
self
.
failUnless
(
'datachunk1datachunk2'
in
out
.
getvalue
())
self
.
assertTrue
(
'datachunk1datachunk2'
in
out
.
getvalue
())
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
...
...
src/ZTUtils/tests/testTree.py
View file @
6220f215
...
@@ -187,7 +187,7 @@ class TreeTests(unittest.TestCase):
...
@@ -187,7 +187,7 @@ class TreeTests(unittest.TestCase):
treeroot1
=
self
.
tm
.
tree
(
self
.
root
,
self
.
expansionmap
)
treeroot1
=
self
.
tm
.
tree
(
self
.
root
,
self
.
expansionmap
)
encoded
=
Tree
.
encodeExpansion
(
treeroot1
.
flat
())
encoded
=
Tree
.
encodeExpansion
(
treeroot1
.
flat
())
self
.
failIf
(
encoded
.
find
(
'
\
n
'
)
!=
-
1
)
self
.
assertFalse
(
encoded
.
find
(
'
\
n
'
)
!=
-
1
)
decodedmap
=
Tree
.
decodeExpansion
(
encoded
)
decodedmap
=
Tree
.
decodeExpansion
(
encoded
)
treeroot2
=
self
.
tm
.
tree
(
self
.
root
,
decodedmap
)
treeroot2
=
self
.
tm
.
tree
(
self
.
root
,
decodedmap
)
...
...
src/Zope2/App/tests/testExceptionHook.py
View file @
6220f215
...
@@ -246,9 +246,9 @@ class ExceptionMessageRenderTest(ExceptionHookTestCase):
...
@@ -246,9 +246,9 @@ class ExceptionMessageRenderTest(ExceptionHookTestCase):
request
=
self
.
_makeRequest
()
request
=
self
.
_makeRequest
()
client
=
StandardClient
()
client
=
StandardClient
()
self
.
call
(
client
,
request
,
f
)
self
.
call
(
client
,
request
,
f
)
self
.
failUnless
(
client
.
messages
,
client
.
messages
)
self
.
assertTrue
(
client
.
messages
,
client
.
messages
)
tb
=
client
.
messages
[
0
]
tb
=
client
.
messages
[
0
]
self
.
failUnless
(
"Unauthorized: You are not allowed"
in
tb
,
tb
)
self
.
assertTrue
(
"Unauthorized: You are not allowed"
in
tb
,
tb
)
def
testRenderUnauthorizedStandardClientMethod
(
self
):
def
testRenderUnauthorizedStandardClientMethod
(
self
):
from
AccessControl
import
Unauthorized
from
AccessControl
import
Unauthorized
...
@@ -257,9 +257,9 @@ class ExceptionMessageRenderTest(ExceptionHookTestCase):
...
@@ -257,9 +257,9 @@ class ExceptionMessageRenderTest(ExceptionHookTestCase):
request
=
self
.
_makeRequest
()
request
=
self
.
_makeRequest
()
client
=
StandardClient
()
client
=
StandardClient
()
self
.
call
(
client
.
dummyMethod
,
request
,
f
)
self
.
call
(
client
.
dummyMethod
,
request
,
f
)
self
.
failUnless
(
client
.
messages
,
client
.
messages
)
self
.
assertTrue
(
client
.
messages
,
client
.
messages
)
tb
=
client
.
messages
[
0
]
tb
=
client
.
messages
[
0
]
self
.
failUnless
(
"Unauthorized: You are not allowed"
in
tb
,
tb
)
self
.
assertTrue
(
"Unauthorized: You are not allowed"
in
tb
,
tb
)
def
testRenderUnauthorizedBrokenClient
(
self
):
def
testRenderUnauthorizedBrokenClient
(
self
):
from
AccessControl
import
Unauthorized
from
AccessControl
import
Unauthorized
...
@@ -283,9 +283,9 @@ class ExceptionMessageRenderTest(ExceptionHookTestCase):
...
@@ -283,9 +283,9 @@ class ExceptionMessageRenderTest(ExceptionHookTestCase):
request
=
self
.
_makeRequest
()
request
=
self
.
_makeRequest
()
client
=
StandardClient
()
client
=
StandardClient
()
self
.
call
(
client
,
request
,
f
)
self
.
call
(
client
,
request
,
f
)
self
.
failUnless
(
client
.
messages
,
client
.
messages
)
self
.
assertTrue
(
client
.
messages
,
client
.
messages
)
tb
=
client
.
messages
[
0
]
tb
=
client
.
messages
[
0
]
self
.
failUnless
(
"CustomException: Zope"
in
tb
,
tb
)
self
.
assertTrue
(
"CustomException: Zope"
in
tb
,
tb
)
def
testRenderRetryRaisesConflictError
(
self
):
def
testRenderRetryRaisesConflictError
(
self
):
from
ZPublisher
import
Retry
from
ZPublisher
import
Retry
...
@@ -300,9 +300,9 @@ class ExceptionMessageRenderTest(ExceptionHookTestCase):
...
@@ -300,9 +300,9 @@ class ExceptionMessageRenderTest(ExceptionHookTestCase):
request
=
self
.
_makeRequest
()
request
=
self
.
_makeRequest
()
client
=
StandardClient
()
client
=
StandardClient
()
self
.
call
(
client
,
request
,
f
)
self
.
call
(
client
,
request
,
f
)
self
.
failUnless
(
client
.
messages
,
client
.
messages
)
self
.
assertTrue
(
client
.
messages
,
client
.
messages
)
tb
=
client
.
messages
[
0
]
tb
=
client
.
messages
[
0
]
self
.
failUnless
(
"ConflictError: database conflict error"
in
tb
,
tb
)
self
.
assertTrue
(
"ConflictError: database conflict error"
in
tb
,
tb
)
class
CustomExceptionView
(
Acquisition
.
Explicit
):
class
CustomExceptionView
(
Acquisition
.
Explicit
):
...
@@ -337,9 +337,9 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
...
@@ -337,9 +337,9 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
request
=
self
.
_makeRequest
()
request
=
self
.
_makeRequest
()
client
=
StandardClient
()
client
=
StandardClient
()
v
=
self
.
call_exc_value
(
client
,
request
,
f
)
v
=
self
.
call_exc_value
(
client
,
request
,
f
)
self
.
failUnless
(
isinstance
(
v
,
Unauthorized
),
v
)
self
.
assertTrue
(
isinstance
(
v
,
Unauthorized
),
v
)
self
.
failUnless
(
"Exception View: Unauthorized"
in
str
(
v
))
self
.
assertTrue
(
"Exception View: Unauthorized"
in
str
(
v
))
self
.
failUnless
(
"Context: StandardClient"
in
str
(
v
))
self
.
assertTrue
(
"Context: StandardClient"
in
str
(
v
))
def
testCustomExceptionViewForbidden
(
self
):
def
testCustomExceptionViewForbidden
(
self
):
from
ZPublisher.HTTPResponse
import
HTTPResponse
from
ZPublisher.HTTPResponse
import
HTTPResponse
...
@@ -350,9 +350,9 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
...
@@ -350,9 +350,9 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
request
=
self
.
_makeRequest
()
request
=
self
.
_makeRequest
()
client
=
StandardClient
()
client
=
StandardClient
()
v
=
self
.
call_exc_value
(
client
,
request
,
f
)
v
=
self
.
call_exc_value
(
client
,
request
,
f
)
self
.
failUnless
(
isinstance
(
v
,
HTTPResponse
),
v
)
self
.
assertTrue
(
isinstance
(
v
,
HTTPResponse
),
v
)
self
.
failUnless
(
v
.
status
==
403
,
(
v
.
status
,
403
))
self
.
assertTrue
(
v
.
status
==
403
,
(
v
.
status
,
403
))
self
.
failUnless
(
"Exception View: Forbidden"
in
str
(
v
))
self
.
assertTrue
(
"Exception View: Forbidden"
in
str
(
v
))
def
testCustomExceptionViewNotFound
(
self
):
def
testCustomExceptionViewNotFound
(
self
):
from
ZPublisher.HTTPResponse
import
HTTPResponse
from
ZPublisher.HTTPResponse
import
HTTPResponse
...
@@ -363,9 +363,9 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
...
@@ -363,9 +363,9 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
request
=
self
.
_makeRequest
()
request
=
self
.
_makeRequest
()
client
=
StandardClient
()
client
=
StandardClient
()
v
=
self
.
call_exc_value
(
client
,
request
,
f
)
v
=
self
.
call_exc_value
(
client
,
request
,
f
)
self
.
failUnless
(
isinstance
(
v
,
HTTPResponse
),
v
)
self
.
assertTrue
(
isinstance
(
v
,
HTTPResponse
),
v
)
self
.
failUnless
(
v
.
status
==
404
,
(
v
.
status
,
404
))
self
.
assertTrue
(
v
.
status
==
404
,
(
v
.
status
,
404
))
self
.
failUnless
(
"Exception View: NotFound"
in
str
(
v
),
v
)
self
.
assertTrue
(
"Exception View: NotFound"
in
str
(
v
),
v
)
def
testCustomExceptionViewBadRequest
(
self
):
def
testCustomExceptionViewBadRequest
(
self
):
from
ZPublisher.HTTPResponse
import
HTTPResponse
from
ZPublisher.HTTPResponse
import
HTTPResponse
...
@@ -376,9 +376,9 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
...
@@ -376,9 +376,9 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
request
=
self
.
_makeRequest
()
request
=
self
.
_makeRequest
()
client
=
StandardClient
()
client
=
StandardClient
()
v
=
self
.
call_exc_value
(
client
,
request
,
f
)
v
=
self
.
call_exc_value
(
client
,
request
,
f
)
self
.
failUnless
(
isinstance
(
v
,
HTTPResponse
),
v
)
self
.
assertTrue
(
isinstance
(
v
,
HTTPResponse
),
v
)
self
.
failUnless
(
v
.
status
==
400
,
(
v
.
status
,
400
))
self
.
assertTrue
(
v
.
status
==
400
,
(
v
.
status
,
400
))
self
.
failUnless
(
"Exception View: BadRequest"
in
str
(
v
),
v
)
self
.
assertTrue
(
"Exception View: BadRequest"
in
str
(
v
),
v
)
def
testCustomExceptionViewInternalError
(
self
):
def
testCustomExceptionViewInternalError
(
self
):
from
ZPublisher.HTTPResponse
import
HTTPResponse
from
ZPublisher.HTTPResponse
import
HTTPResponse
...
@@ -389,9 +389,9 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
...
@@ -389,9 +389,9 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
request
=
self
.
_makeRequest
()
request
=
self
.
_makeRequest
()
client
=
StandardClient
()
client
=
StandardClient
()
v
=
self
.
call_exc_value
(
client
,
request
,
f
)
v
=
self
.
call_exc_value
(
client
,
request
,
f
)
self
.
failUnless
(
isinstance
(
v
,
HTTPResponse
),
v
)
self
.
assertTrue
(
isinstance
(
v
,
HTTPResponse
),
v
)
self
.
failUnless
(
v
.
status
==
500
,
(
v
.
status
,
500
))
self
.
assertTrue
(
v
.
status
==
500
,
(
v
.
status
,
500
))
self
.
failUnless
(
"Exception View: InternalError"
in
str
(
v
),
v
)
self
.
assertTrue
(
"Exception View: InternalError"
in
str
(
v
),
v
)
def
testRedirectNoExceptionView
(
self
):
def
testRedirectNoExceptionView
(
self
):
from
zExceptions
import
Redirect
from
zExceptions
import
Redirect
...
@@ -401,7 +401,7 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
...
@@ -401,7 +401,7 @@ class ExceptionViewsTest(PlacelessSetup, ExceptionHookTestCase):
request
=
self
.
_makeRequest
()
request
=
self
.
_makeRequest
()
client
=
StandardClient
()
client
=
StandardClient
()
v
=
self
.
call_exc_value
(
client
,
request
,
f
)
v
=
self
.
call_exc_value
(
client
,
request
,
f
)
self
.
failUnless
(
isinstance
(
v
,
Redirect
),
v
)
self
.
assertTrue
(
isinstance
(
v
,
Redirect
),
v
)
self
.
assertEquals
(
v
.
args
[
0
],
"http://zope.org/"
)
self
.
assertEquals
(
v
.
args
[
0
],
"http://zope.org/"
)
...
...
src/Zope2/App/tests/test_schema.py
View file @
6220f215
...
@@ -49,4 +49,4 @@ class Zope2VocabularyRegistryTests(unittest.TestCase, CleanUp):
...
@@ -49,4 +49,4 @@ class Zope2VocabularyRegistryTests(unittest.TestCase, CleanUp):
registry
=
self
.
_makeOne
()
registry
=
self
.
_makeOne
()
context
=
object
()
context
=
object
()
found
=
registry
.
get
(
context
,
'foundit'
)
found
=
registry
.
get
(
context
,
'foundit'
)
self
.
failUnless
(
found
is
_marker
)
self
.
assertTrue
(
found
is
_marker
)
src/Zope2/Startup/tests/testStarter.py
View file @
6220f215
...
@@ -254,7 +254,7 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase):
...
@@ -254,7 +254,7 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase):
effective-user %s"""
%
runnerid
)
effective-user %s"""
%
runnerid
)
starter
=
make_starter
(
conf
)
starter
=
make_starter
(
conf
)
finished
=
starter
.
dropPrivileges
()
finished
=
starter
.
dropPrivileges
()
self
.
failUnless
(
finished
)
self
.
assertTrue
(
finished
)
finally
:
finally
:
os
.
getuid
=
_old_getuid
os
.
getuid
=
_old_getuid
...
@@ -292,9 +292,9 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase):
...
@@ -292,9 +292,9 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase):
logger
=
logging
.
getLogger
()
logger
=
logging
.
getLogger
()
self
.
assertEqual
(
logger
.
level
,
logging
.
INFO
)
self
.
assertEqual
(
logger
.
level
,
logging
.
INFO
)
l
=
open
(
os
.
path
.
join
(
TEMPNAME
,
'event.log'
)).
read
()
l
=
open
(
os
.
path
.
join
(
TEMPNAME
,
'event.log'
)).
read
()
self
.
failUnless
(
l
.
find
(
'hello'
)
>
-
1
)
self
.
assertTrue
(
l
.
find
(
'hello'
)
>
-
1
)
self
.
failUnless
(
os
.
path
.
exists
(
os
.
path
.
join
(
TEMPNAME
,
'Z2.log'
)))
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
path
.
join
(
TEMPNAME
,
'Z2.log'
)))
self
.
failUnless
(
os
.
path
.
exists
(
os
.
path
.
join
(
TEMPNAME
,
'trace.log'
)))
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
path
.
join
(
TEMPNAME
,
'trace.log'
)))
finally
:
finally
:
for
name
in
(
'event.log'
,
'Z2.log'
,
'trace.log'
):
for
name
in
(
'event.log'
,
'Z2.log'
,
'trace.log'
):
try
:
try
:
...
@@ -326,10 +326,10 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase):
...
@@ -326,10 +326,10 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase):
f
.
seek
(
1
)
# skip over the locked byte
f
.
seek
(
1
)
# skip over the locked byte
guts
=
f
.
read
()
guts
=
f
.
read
()
f
.
close
()
f
.
close
()
self
.
failIf
(
guts
.
find
(
'hello'
)
>
-
1
)
self
.
assertFalse
(
guts
.
find
(
'hello'
)
>
-
1
)
finally
:
finally
:
starter
.
unlinkLockFile
()
starter
.
unlinkLockFile
()
self
.
failIf
(
os
.
path
.
exists
(
name
))
self
.
assertFalse
(
os
.
path
.
exists
(
name
))
def
testMakePidFile
(
self
):
def
testMakePidFile
(
self
):
# put something in the way (it should be deleted)
# put something in the way (it should be deleted)
...
@@ -344,10 +344,10 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase):
...
@@ -344,10 +344,10 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase):
try
:
try
:
starter
=
self
.
get_starter
(
conf
)
starter
=
self
.
get_starter
(
conf
)
starter
.
makePidFile
()
starter
.
makePidFile
()
self
.
failIf
(
open
(
name
).
read
().
find
(
'hello'
)
>
-
1
)
self
.
assertFalse
(
open
(
name
).
read
().
find
(
'hello'
)
>
-
1
)
finally
:
finally
:
starter
.
unlinkPidFile
()
starter
.
unlinkPidFile
()
self
.
failIf
(
os
.
path
.
exists
(
name
))
self
.
assertFalse
(
os
.
path
.
exists
(
name
))
def
testConfigureInterpreter
(
self
):
def
testConfigureInterpreter
(
self
):
import
sys
import
sys
...
...
src/reStructuredText/tests/testReST.py
View file @
6220f215
...
@@ -147,12 +147,12 @@ text
...
@@ -147,12 +147,12 @@ text
def
test_csv_table_file_option_raise
(
self
):
def
test_csv_table_file_option_raise
(
self
):
source
=
'.. csv-table::
\
n
:file: inclusion.txt'
source
=
'.. csv-table::
\
n
:file: inclusion.txt'
result
=
HTML
(
source
)
result
=
HTML
(
source
)
self
.
failUnless
(
'File and URL access deactivated'
in
result
)
self
.
assertTrue
(
'File and URL access deactivated'
in
result
)
def
test_csv_table_url_option_raise
(
self
):
def
test_csv_table_url_option_raise
(
self
):
source
=
'.. csv-table::
\
n
:url: http://www.evil.org'
source
=
'.. csv-table::
\
n
:url: http://www.evil.org'
result
=
HTML
(
source
)
result
=
HTML
(
source
)
self
.
failUnless
(
'File and URL access deactivated'
in
result
)
self
.
assertTrue
(
'File and URL access deactivated'
in
result
)
def
test_suite
():
def
test_suite
():
...
...
src/webdav/tests/testLockable.py
View file @
6220f215
...
@@ -4,18 +4,18 @@ class TestUtilFunctions(unittest.TestCase):
...
@@ -4,18 +4,18 @@ class TestUtilFunctions(unittest.TestCase):
def
test_wl_isLocked
(
self
):
def
test_wl_isLocked
(
self
):
from
webdav.Lockable
import
wl_isLocked
from
webdav.Lockable
import
wl_isLocked
unlockable
=
UnlockableResource
()
unlockable
=
UnlockableResource
()
self
.
failIf
(
wl_isLocked
(
unlockable
))
self
.
assertFalse
(
wl_isLocked
(
unlockable
))
lockable_unlocked
=
LockableResource
(
locked
=
False
)
lockable_unlocked
=
LockableResource
(
locked
=
False
)
self
.
failIf
(
wl_isLocked
(
lockable_unlocked
))
self
.
assertFalse
(
wl_isLocked
(
lockable_unlocked
))
lockable_locked
=
LockableResource
(
locked
=
True
)
lockable_locked
=
LockableResource
(
locked
=
True
)
self
.
failUnless
(
wl_isLocked
(
lockable_locked
))
self
.
assertTrue
(
wl_isLocked
(
lockable_locked
))
def
test_wl_isLockable
(
self
):
def
test_wl_isLockable
(
self
):
from
webdav.Lockable
import
wl_isLockable
from
webdav.Lockable
import
wl_isLockable
unlockable
=
UnlockableResource
()
unlockable
=
UnlockableResource
()
self
.
failIf
(
wl_isLockable
(
unlockable
))
self
.
assertFalse
(
wl_isLockable
(
unlockable
))
lockable
=
LockableResource
(
locked
=
False
)
lockable
=
LockableResource
(
locked
=
False
)
self
.
failUnless
(
wl_isLockable
(
lockable
))
self
.
assertTrue
(
wl_isLockable
(
lockable
))
from
webdav.interfaces
import
IWriteLock
from
webdav.interfaces
import
IWriteLock
from
zope.interface
import
implements
from
zope.interface
import
implements
...
...
src/webdav/tests/testNullResource.py
View file @
6220f215
...
@@ -46,7 +46,7 @@ class TestNullResource(unittest.TestCase):
...
@@ -46,7 +46,7 @@ class TestNullResource(unittest.TestCase):
self
.
assertRaises
(
NotFound
,
nonesuch
.
HEAD
,
request
,
response
)
self
.
assertRaises
(
NotFound
,
nonesuch
.
HEAD
,
request
,
response
)
self
.
assertEqual
(
response
.
body
,
''
)
self
.
assertEqual
(
response
.
body
,
''
)
self
.
failUnless
(
response
.
locked
)
self
.
assertTrue
(
response
.
locked
)
def
test_PUT_unauthorized_message
(
self
):
def
test_PUT_unauthorized_message
(
self
):
# See https://bugs.launchpad.net/bugs/143946
# See https://bugs.launchpad.net/bugs/143946
...
@@ -73,7 +73,7 @@ class TestNullResource(unittest.TestCase):
...
@@ -73,7 +73,7 @@ class TestNullResource(unittest.TestCase):
try
:
try
:
nonesuch
.
PUT
(
request
,
response
)
nonesuch
.
PUT
(
request
,
response
)
except
Unauthorized
,
e
:
except
Unauthorized
,
e
:
self
.
failUnless
(
str
(
e
).
startswith
(
'Unable to create object'
))
self
.
assertTrue
(
str
(
e
).
startswith
(
'Unable to create object'
))
def
test_suite
():
def
test_suite
():
...
...
src/webdav/tests/testPUT_factory.py
View file @
6220f215
...
@@ -42,31 +42,31 @@ class TestPUTFactory(unittest.TestCase):
...
@@ -42,31 +42,31 @@ class TestPUTFactory(unittest.TestCase):
request
=
self
.
app
.
REQUEST
request
=
self
.
app
.
REQUEST
put
=
request
.
traverse
(
'/folder/doc'
)
put
=
request
.
traverse
(
'/folder/doc'
)
put
(
request
,
request
.
RESPONSE
)
put
(
request
,
request
.
RESPONSE
)
self
.
failUnless
(
'doc'
in
self
.
folder
.
objectIds
())
self
.
assertTrue
(
'doc'
in
self
.
folder
.
objectIds
())
def
testSimpleVirtualHosting
(
self
):
def
testSimpleVirtualHosting
(
self
):
request
=
self
.
app
.
REQUEST
request
=
self
.
app
.
REQUEST
put
=
request
.
traverse
(
'/VirtualHostBase/http/foo.com:80/VirtualHostRoot/folder/doc'
)
put
=
request
.
traverse
(
'/VirtualHostBase/http/foo.com:80/VirtualHostRoot/folder/doc'
)
put
(
request
,
request
.
RESPONSE
)
put
(
request
,
request
.
RESPONSE
)
self
.
failUnless
(
'doc'
in
self
.
folder
.
objectIds
())
self
.
assertTrue
(
'doc'
in
self
.
folder
.
objectIds
())
def
testSubfolderVirtualHosting
(
self
):
def
testSubfolderVirtualHosting
(
self
):
request
=
self
.
app
.
REQUEST
request
=
self
.
app
.
REQUEST
put
=
request
.
traverse
(
'/VirtualHostBase/http/foo.com:80/folder/VirtualHostRoot/doc'
)
put
=
request
.
traverse
(
'/VirtualHostBase/http/foo.com:80/folder/VirtualHostRoot/doc'
)
put
(
request
,
request
.
RESPONSE
)
put
(
request
,
request
.
RESPONSE
)
self
.
failUnless
(
'doc'
in
self
.
folder
.
objectIds
())
self
.
assertTrue
(
'doc'
in
self
.
folder
.
objectIds
())
def
testInsideOutVirtualHosting
(
self
):
def
testInsideOutVirtualHosting
(
self
):
request
=
self
.
app
.
REQUEST
request
=
self
.
app
.
REQUEST
put
=
request
.
traverse
(
'/VirtualHostBase/http/foo.com:80/VirtualHostRoot/_vh_foo/folder/doc'
)
put
=
request
.
traverse
(
'/VirtualHostBase/http/foo.com:80/VirtualHostRoot/_vh_foo/folder/doc'
)
put
(
request
,
request
.
RESPONSE
)
put
(
request
,
request
.
RESPONSE
)
self
.
failUnless
(
'doc'
in
self
.
folder
.
objectIds
())
self
.
assertTrue
(
'doc'
in
self
.
folder
.
objectIds
())
def
testSubfolderInsideOutVirtualHosting
(
self
):
def
testSubfolderInsideOutVirtualHosting
(
self
):
request
=
self
.
app
.
REQUEST
request
=
self
.
app
.
REQUEST
put
=
request
.
traverse
(
'/VirtualHostBase/http/foo.com:80/folder/VirtualHostRoot/_vh_foo/doc'
)
put
=
request
.
traverse
(
'/VirtualHostBase/http/foo.com:80/folder/VirtualHostRoot/_vh_foo/doc'
)
put
(
request
,
request
.
RESPONSE
)
put
(
request
,
request
.
RESPONSE
)
self
.
failUnless
(
'doc'
in
self
.
folder
.
objectIds
())
self
.
assertTrue
(
'doc'
in
self
.
folder
.
objectIds
())
def
testCollector2261
(
self
):
def
testCollector2261
(
self
):
from
OFS.Folder
import
manage_addFolder
from
OFS.Folder
import
manage_addFolder
...
...
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