Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
package_control_channel
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gaurav Kukreja
package_control_channel
Commits
02416140
Commit
02416140
authored
Jul 16, 2015
by
FichteFoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch TestSuite for setUpClass and tearDownClass
The unittest module sure is weird ...
parent
728785c3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
10 deletions
+24
-10
unittest_compat.py
tests/unittest_compat.py
+24
-10
No files found.
tests/unittest_compat.py
View file @
02416140
...
@@ -62,18 +62,32 @@ def inject_into_unittest():
...
@@ -62,18 +62,32 @@ def inject_into_unittest():
msg
=
'
%
s is not an instance of
%
r'
%
(
obj
,
cls
)
msg
=
'
%
s is not an instance of
%
r'
%
(
obj
,
cls
)
self
.
fail
(
msg
)
self
.
fail
(
msg
)
# Patch in setUpClass
unittest
.
TestCase
=
PatchedTestCase
@
wraps
(
unittest
.
TestCase
.
setUp
)
# no need to call, it's just `pass`
def
setUp
(
self
):
cls
=
self
.
__class__
if
not
hasattr
(
self
,
'_class_set_up'
):
self
.
_class_set_up
=
True
if
hasattr
(
cls
,
"setUpClass"
):
cls
.
setUpClass
()
# TODO tearDownClass
# Patch setUpClass and tearDownClass into unittest.TestSuite
def
run
(
self
,
result
):
def
run_if_attr
(
obj
,
attrname
):
method
=
getattr
(
obj
,
attrname
,
None
)
if
method
:
method
()
unittest
.
TestCase
=
PatchedTestCase
last_class
=
None
for
test
in
self
.
_tests
:
if
last_class
.
__class__
!=
test
.
__class__
:
if
last_class
is
not
None
:
run_if_attr
(
last_class
,
'tearDownClass'
)
last_class
=
test
.
__class__
run_if_attr
(
last_class
,
'setUpClass'
)
if
result
.
shouldStop
:
break
test
(
result
)
if
last_class
is
not
None
:
run_if_attr
(
last_class
,
'tearDownClass'
)
return
result
unittest
.
TestSuite
.
run
=
run
elif
sys
.
version_info
<
(
3
,
2
):
elif
sys
.
version_info
<
(
3
,
2
):
unittest
.
TestCase
.
assertRegex
=
unittest
.
TestCase
.
assertRegexpMatches
unittest
.
TestCase
.
assertRegex
=
unittest
.
TestCase
.
assertRegexpMatches
...
...
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