Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cloudooo
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
cloudooo
Commits
bfaa8391
Commit
bfaa8391
authored
Sep 25, 2013
by
Gabriel Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Fix script to run unit tests follow changes from erp5.git"
This reverts commit
da0b08a7
.
parent
da0b08a7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
28 deletions
+41
-28
cloudooo/tests/backportUnittest.py
cloudooo/tests/backportUnittest.py
+41
-28
No files found.
cloudooo/tests/backportUnittest.py
View file @
bfaa8391
...
@@ -91,14 +91,28 @@ def expectedFailure(func):
...
@@ -91,14 +91,28 @@ def expectedFailure(func):
wrapper
.
__doc__
=
func
.
__doc__
wrapper
.
__doc__
=
func
.
__doc__
return
wrapper
return
wrapper
try
:
BaseException
except
NameError
:
# BACK: python < 2.5
BaseException
=
Exception
class
TestCase
(
unittest
.
TestCase
):
class
TestCase
(
unittest
.
TestCase
):
"""We redefine here the run() method, and add a skipTest() method.
"""We redefine here the run() method, and add a skipTest() method.
We also provide forward-compatible ._testMethodName and ._testMethodDoc
properties smooth over differences between Python 2.4 and 2.5+.
"""
"""
failureException
=
AssertionError
failureException
=
AssertionError
if
sys
.
version_info
<
(
2
,
5
):
# BACK: in Python 2.5, __testMethodName becomes _testMethodName.
# Same for __testMethodDoc
_testMethodName
=
property
(
lambda
self
:
self
.
__testMethodName
)
_testMethodDoc
=
property
(
lambda
self
:
self
.
__testMethodDoc
)
def
run
(
self
,
result
=
None
):
def
run
(
self
,
result
=
None
):
orig_result
=
result
if
result
is
None
:
if
result
is
None
:
result
=
self
.
defaultTestResult
()
result
=
self
.
defaultTestResult
()
# BACK: Not necessary for Python < 2.7:
# BACK: Not necessary for Python < 2.7:
...
@@ -176,12 +190,12 @@ class TestCase(unittest.TestCase):
...
@@ -176,12 +190,12 @@ class TestCase(unittest.TestCase):
"""Skip this test."""
"""Skip this test."""
raise
SkipTest
(
reason
)
raise
SkipTest
(
reason
)
if
not
hasattr
(
unittest
.
TestResult
,
'addSkip'
):
# BBB: Python < 2.7
def
defaultTestResult
(
self
):
return
TestResult
()
unittest
.
TestResult
.
_orig_init__
=
unittest
.
TestResult
.
__init__
.
im_func
class
TestResult
(
unittest
.
TestResult
):
def
__init__
(
self
):
def
__init__
(
self
):
s
elf
.
_orig
_init__
()
s
uper
(
TestResult
,
self
).
_
_init__
()
self
.
skipped
=
[]
self
.
skipped
=
[]
self
.
expectedFailures
=
[]
self
.
expectedFailures
=
[]
self
.
unexpectedSuccesses
=
[]
self
.
unexpectedSuccesses
=
[]
...
@@ -189,6 +203,26 @@ if not hasattr(unittest.TestResult, 'addSkip'): # BBB: Python < 2.7
...
@@ -189,6 +203,26 @@ if not hasattr(unittest.TestResult, 'addSkip'): # BBB: Python < 2.7
def
addSkip
(
self
,
test
,
reason
):
def
addSkip
(
self
,
test
,
reason
):
"""Called when a test is skipped."""
"""Called when a test is skipped."""
self
.
skipped
.
append
((
test
,
reason
))
self
.
skipped
.
append
((
test
,
reason
))
def
addExpectedFailure
(
self
,
test
,
err
):
"""Called when an expected failure/error occured."""
self
.
expectedFailures
.
append
(
(
test
,
self
.
_exc_info_to_string
(
err
,
test
)))
def
addUnexpectedSuccess
(
self
,
test
):
"""Called when a test was expected to fail, but succeed."""
self
.
unexpectedSuccesses
.
append
(
test
)
class
_TextTestResult
(
unittest
.
_TextTestResult
,
TestResult
):
def
__init__
(
self
,
stream
,
descriptions
,
verbosity
):
# BACK: nice diamond!
# unittest.TestResult.__init__ is called twice here
unittest
.
_TextTestResult
.
__init__
(
self
,
stream
,
descriptions
,
verbosity
)
TestResult
.
__init__
(
self
)
def
addSkip
(
self
,
test
,
reason
):
super
(
_TextTestResult
,
self
).
addSkip
(
test
,
reason
)
if
self
.
showAll
:
if
self
.
showAll
:
self
.
stream
.
writeln
(
"skipped %s"
%
repr
(
reason
))
self
.
stream
.
writeln
(
"skipped %s"
%
repr
(
reason
))
elif
self
.
dots
:
elif
self
.
dots
:
...
@@ -196,9 +230,7 @@ if not hasattr(unittest.TestResult, 'addSkip'): # BBB: Python < 2.7
...
@@ -196,9 +230,7 @@ if not hasattr(unittest.TestResult, 'addSkip'): # BBB: Python < 2.7
self
.
stream
.
flush
()
self
.
stream
.
flush
()
def
addExpectedFailure
(
self
,
test
,
err
):
def
addExpectedFailure
(
self
,
test
,
err
):
"""Called when an expected failure/error occured."""
super
(
_TextTestResult
,
self
).
addExpectedFailure
(
test
,
err
)
self
.
expectedFailures
.
append
(
(
test
,
self
.
_exc_info_to_string
(
err
,
test
)))
if
self
.
showAll
:
if
self
.
showAll
:
self
.
stream
.
writeln
(
"expected failure"
)
self
.
stream
.
writeln
(
"expected failure"
)
elif
self
.
dots
:
elif
self
.
dots
:
...
@@ -206,32 +238,13 @@ if not hasattr(unittest.TestResult, 'addSkip'): # BBB: Python < 2.7
...
@@ -206,32 +238,13 @@ if not hasattr(unittest.TestResult, 'addSkip'): # BBB: Python < 2.7
self
.
stream
.
flush
()
self
.
stream
.
flush
()
def
addUnexpectedSuccess
(
self
,
test
):
def
addUnexpectedSuccess
(
self
,
test
):
"""Called when a test was expected to fail, but succeed."""
super
(
_TextTestResult
,
self
).
addUnexpectedSuccess
(
test
)
self
.
unexpectedSuccesses
.
append
(
test
)
if
self
.
showAll
:
if
self
.
showAll
:
self
.
stream
.
writeln
(
"unexpected success"
)
self
.
stream
.
writeln
(
"unexpected success"
)
elif
self
.
dots
:
elif
self
.
dots
:
self
.
stream
.
write
(
"u"
)
self
.
stream
.
write
(
"u"
)
self
.
stream
.
flush
()
self
.
stream
.
flush
()
for
f
in
__init__
,
addSkip
,
addExpectedFailure
,
addUnexpectedSuccess
:
setattr
(
unittest
.
TestResult
,
f
.
__name__
,
f
)
def
getDescription
(
self
,
test
):
doc_first_line
=
test
.
shortDescription
()
if
self
.
descriptions
and
doc_first_line
:
return
'
\
n
'
.
join
((
str
(
test
),
doc_first_line
))
else
:
return
str
(
test
)
unittest
.
_TextTestResult
.
getDescription
=
getDescription
class
_TextTestResult
(
unittest
.
_TextTestResult
):
def
wasSuccessful
(
self
):
"Tells whether or not this result was a success"
return
not
(
self
.
failures
or
self
.
errors
or
self
.
unexpectedSuccesses
)
def
printErrors
(
self
):
def
printErrors
(
self
):
if
self
.
dots
or
self
.
showAll
:
if
self
.
dots
or
self
.
showAll
:
self
.
stream
.
writeln
()
self
.
stream
.
writeln
()
...
...
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