Skip to content

Commit

Permalink
Extend error message on InputPrefixNotFound (timeout subclass)
Browse files Browse the repository at this point in the history
  • Loading branch information
eldipa committed Jan 23, 2020
1 parent 8b8b58a commit ce3f7a9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions byexample/modules/progress.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import unicode_literals
import traceback, time, os, sys, multiprocessing
from byexample.executor import InputPrefixNotFound
from byexample.common import colored, highlight_syntax, indent
from byexample.concern import Concern

Expand Down Expand Up @@ -131,6 +132,15 @@ def timedout(self, example, exception):
'with +timeout=<n>) or the example is "syntactically incorrect" and\n' + \
'the interpreter hang (may be you forgot a parenthesis or something like that?).\n'

if isinstance(exception, InputPrefixNotFound):
input = exception.input
if len(input) > 14:
input = input[:6] + '..' + input[-6:]

msg += ("This happen before typing '%s'.\n" % input) + \
"Perhaps the text before did not match what you expected?\n" + \
(exception.prefix) + '\n'

if exception.output:
msg += 'This is the last output obtained:\n%s\n' % str(
exception.output
Expand Down

0 comments on commit ce3f7a9

Please sign in to comment.