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
0c0f0721
Commit
0c0f0721
authored
Aug 29, 2004
by
Jens Vagelpohl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Adding a basis test suite to the SiteErrorLog
parent
5d2fdec3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
0 deletions
+108
-0
lib/python/Products/SiteErrorLog/tests/__init__.py
lib/python/Products/SiteErrorLog/tests/__init__.py
+1
-0
lib/python/Products/SiteErrorLog/tests/testSiteErrorLog.py
lib/python/Products/SiteErrorLog/tests/testSiteErrorLog.py
+107
-0
No files found.
lib/python/Products/SiteErrorLog/tests/__init__.py
0 → 100644
View file @
0c0f0721
# SiteErrorLog test package
lib/python/Products/SiteErrorLog/tests/testSiteErrorLog.py
0 → 100644
View file @
0c0f0721
"""SiteErrorLog tests
Note: Tests require Zope >= 2.7
$Id: testVirtualHostMonster.py 24763 2004-05-17 05:59:28Z philikon $
"""
from
Testing.makerequest
import
makerequest
import
Zope
Zope
.
startup
()
import
sys
import
unittest
class
SiteErrorLogTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
get_transaction
().
begin
()
self
.
app
=
makerequest
(
Zope
.
app
())
try
:
self
.
app
.
manage_addDTMLMethod
(
'doc'
,
''
)
except
:
self
.
tearDown
()
def
tearDown
(
self
):
get_transaction
().
abort
()
self
.
app
.
_p_jar
.
close
()
def
testInstantiation
(
self
):
# Retrieve the error_log by ID
sel_ob
=
getattr
(
self
.
app
,
'error_log'
,
None
)
# Does the error log exist?
self
.
assert_
(
sel_ob
is
not
None
)
# Is the __error_log__ hook in place?
self
.
assert_
(
self
.
app
.
__error_log__
==
sel_ob
)
# Right now there should not be any entries in the log
self
.
assertEquals
(
len
(
sel_ob
.
getLogEntries
()),
0
)
def
testSimpleException
(
self
):
# Grab the Site Error Log and make sure it's empty
sel_ob
=
self
.
app
.
error_log
previous_log_length
=
len
(
sel_ob
.
getLogEntries
())
# Fill the DTML method at self.root.doc with bogus code
dmeth
=
self
.
app
.
doc
dmeth
.
manage_upload
(
file
=
"""<dtml-var expr="1/0">"""
)
# "Faking out" the automatic involvement of the Site Error Log
# by manually calling the method "raising" that gets invoked
# automatically in a normal web request environment.
try
:
dmeth
.
__call__
()
except
ZeroDivisionError
:
sel_ob
.
raising
(
sys
.
exc_info
())
# Now look at the SiteErrorLog, it has one more log entry
self
.
assertEquals
(
len
(
sel_ob
.
getLogEntries
()),
previous_log_length
+
1
)
def
testIgnoredException
(
self
):
# Grab the Site Error Log
sel_ob
=
self
.
app
.
error_log
previous_log_length
=
len
(
sel_ob
.
getLogEntries
())
# Tell the SiteErrorLog to ignore ZeroDivisionErrors
current_props
=
sel_ob
.
getProperties
()
ignored
=
list
(
current_props
[
'ignored_exceptions'
])
ignored
.
append
(
'ZeroDivisionError'
)
sel_ob
.
setProperties
(
current_props
[
'keep_entries'
]
,
copy_to_zlog
=
current_props
[
'copy_to_zlog'
]
,
ignored_exceptions
=
ignored
)
# Fill the DTML method at self.root.doc with bogus code
dmeth
=
self
.
app
.
doc
dmeth
.
manage_upload
(
file
=
"""<dtml-var expr="1/0">"""
)
# "Faking out" the automatic involvement of the Site Error Log
# by manually calling the method "raising" that gets invoked
# automatically in a normal web request environment.
try
:
dmeth
.
__call__
()
except
ZeroDivisionError
:
sel_ob
.
raising
(
sys
.
exc_info
())
# Now look at the SiteErrorLog, it must have the same number of
# log entries
self
.
assertEquals
(
len
(
sel_ob
.
getLogEntries
()),
previous_log_length
)
def
testCleanup
(
self
):
# Need to make sure that the __error_log__ hook gets cleaned up
self
.
app
.
_delObject
(
'error_log'
)
self
.
assertEquals
(
getattr
(
self
.
app
,
'__error_log__'
,
None
),
None
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
SiteErrorLogTests
))
return
suite
if
__name__
==
'__main__'
:
unittest
.
main
(
defaultTest
=
'test_suite'
)
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