Skip to content

Commit

Permalink
TODO ADD TESTS riotnode: Remove exception context from inside pexpect…
Browse files Browse the repository at this point in the history
… implementation

TODO:
* add tests
* Try to make as if the exception was raised from one level on top!
  So without even being in the `TermSpawn` implementation

This allows having a nicely printed output on `pytest`.
This could be moved outside of here too.
  • Loading branch information
cladmi committed Mar 23, 2019
1 parent 67c4d46 commit 9ce1f1b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dist/pythonlibs/riotnode/riotnode/node.py
Expand Up @@ -25,6 +25,7 @@ class TermSpawn(pexpect.spawn):
* default timeout
* tweak exception:
* replace the value with the called pattern
* remove exception context from inside pexpect implementation
"""

def __init__(self, # pylint:disable=too-many-arguments
Expand Down Expand Up @@ -53,9 +54,14 @@ def _pexpect_exception(exc, pattern):
"""Tweak pexpect exception.
* Put the calling 'pattern' as value
* Remove exception context
"""
exc.pexpect_value = exc.value
exc.value = pattern

# Remove exception context
exc.__cause__ = None
exc.__traceback__ = None
return exc


Expand Down

0 comments on commit 9ce1f1b

Please sign in to comment.