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
Bliss
bliss
Commits
4f050f8a
Commit
4f050f8a
authored
Jul 05, 2021
by
Matias Guijarro
Browse files
tests: make a fixture for excepthook in shell
parent
918d0c37
Changes
1
Show whitespace changes
Inline
Side-by-side
tests/shell/test_bliss_shell_basics.py
View file @
4f050f8a
...
...
@@ -545,15 +545,22 @@ def test_getattribute_evaluation():
result
,
cli
,
_
=
_feed_cli_with_input
(
"a.foo()
\r
"
,
local_globals
=
{
"a"
:
a
})
def
test_excepthook
(
default_session
):
@
pytest
.
fixture
def
shell_excepthook
():
orig_excepthook
=
sys
.
excepthook
try
:
install_excepthook
()
yield
finally
:
sys
.
excepthook
=
orig_excepthook
def
test_excepthook
(
shell_excepthook
,
default_session
):
print_output
=
[]
def
test_print
(
*
msg
,
**
kw
):
print_output
.
append
(
"
\n
"
.
join
(
msg
))
orig_excepthook
=
sys
.
excepthook
try
:
install_excepthook
()
logging
.
getLogger
(
"exceptions"
).
setLevel
(
1000
)
# this is to silent exception logging via logger (which also calls 'print')
...
...
@@ -563,8 +570,6 @@ def test_excepthook(default_session):
raise
RuntimeError
(
"excepthook test"
)
except
RuntimeError
:
sys
.
excepthook
(
*
sys
.
exc_info
())
finally
:
sys
.
excepthook
=
orig_excepthook
assert
(
""
.
join
(
print_output
)
...
...
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