Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubicweb
Commits
58f132392cba
Commit
32bb941c
authored
Jul 22, 2019
by
Denis Laxalde
Browse files
[test] use self.assertRaises() in cwctl tests
parent
5e7212209ea6
Changes
1
Hide whitespace changes
Inline
Side-by-side
cubicweb/test/unittest_cwctl.py
View file @
58f13239
...
...
@@ -113,28 +113,26 @@ class InstanceCommandTest(unittest.TestCase):
@
patch
.
object
(
_TestCommand
,
'test_instance'
,
return_value
=
0
)
def
test_getting_called
(
self
,
test_instance
):
try
:
with
self
.
assertRaises
(
SystemExit
)
as
cm
:
self
.
CWCTL
.
run
([
"test"
,
"some_instance"
])
except
SystemExit
as
ex
:
# CWCTL will finish the program after that
self
.
assertEqual
(
ex
.
code
,
0
)
self
.
assertEqual
(
cm
.
exception
.
code
,
0
)
test_instance
.
assert_called_with
(
"some_instance"
)
@
patch
.
object
(
cwctl
,
'get_pdb'
)
def
test_pdb_not_called
(
self
,
get_pdb
):
try
:
# CWCTL will finish the program after that
with
self
.
assertRaises
(
SystemExit
)
as
cm
:
self
.
CWCTL
.
run
([
"test"
,
"some_instance"
])
except
SystemExit
as
ex
:
# CWCTL will finish the program after that
self
.
assertEqual
(
ex
.
code
,
0
)
self
.
assertEqual
(
cm
.
exception
.
code
,
0
)
get_pdb
.
assert_not_called
()
@
patch
.
object
(
cwctl
,
'get_pdb'
)
def
test_pdb_called
(
self
,
get_pdb
):
post_mortem
=
get_pdb
.
return_value
.
post_mortem
try
:
with
self
.
assertRaises
(
SystemExit
)
as
cm
:
self
.
CWCTL
.
run
([
"test_fail"
,
"some_instance"
,
"--pdb"
])
except
SystemExit
as
ex
:
# CWCTL will finish the program after that
self
.
assertEqual
(
ex
.
code
,
8
)
self
.
assertEqual
(
cm
.
exception
.
code
,
8
)
get_pdb
.
assert_called_once
()
post_mortem
.
assert_called_once
()
...
...
@@ -142,10 +140,9 @@ class InstanceCommandTest(unittest.TestCase):
@
patch
.
dict
(
sys
.
modules
,
ipdb
=
MagicMock
())
def
test_ipdb_selected_and_called
(
self
):
ipdb
=
sys
.
modules
[
'ipdb'
]
try
:
with
self
.
assertRaises
(
SystemExit
)
as
cm
:
self
.
CWCTL
.
run
([
"test_fail"
,
"some_instance"
,
"--pdb"
])
except
SystemExit
as
ex
:
# CWCTL will finish the program after that
self
.
assertEqual
(
ex
.
code
,
8
)
self
.
assertEqual
(
cm
.
exception
.
code
,
8
)
ipdb
.
post_mortem
.
assert_called_once
()
...
...
Write
Preview
Supports
Markdown
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