| 1 |
# -*- coding: UTF-8 |
| 2 |
""" |
| 3 |
Test issue #458: |
| 4 |
|
| 5 |
Traceback (most recent call last): |
| 6 |
File "/usr/local/bin/behave", line 11, in <module> |
| 7 |
sys.exit(main()) |
| 8 |
File "/Library/Python/2.7/site-packages/behave/__main__.py", line 123, in main |
| 9 |
print(u"Exception %s: %s" % (e.__class__.__name__, text)) |
| 10 |
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 69: ordinal not in range(128) |
| 11 |
|
| 12 |
|
| 13 |
try: |
| 14 |
failed = runner.run() |
| 15 |
except ParserError as e: |
| 16 |
print(u"ParseError: %s" % e) |
| 17 |
except ConfigError as e: |
| 18 |
print(u"ConfigError: %s" % e) |
| 19 |
except FileNotFoundError as e: |
| 20 |
print(u"FileNotFoundError: %s" % e) |
| 21 |
except InvalidFileLocationError as e: |
| 22 |
print(u"InvalidFileLocationError: %s" % e) |
| 23 |
except InvalidFilenameError as e: |
| 24 |
print(u"InvalidFilenameError: %s" % e) |
| 25 |
except Exception as e: |
| 26 |
# -- DIAGNOSTICS: |
| 27 |
text = _text(e) |
| 28 |
print(u"Exception %s: %s" % (e.__class__.__name__, text)) |
| 29 |
raise |
| 30 |
""" |
| 31 |
|
| 32 |
from behave.textutil import text as _text |
| 33 |
import pytest |
| 34 |
|
| 35 |
|
| 36 |
def raise_exception(exception_class, message): |
| 37 |
raise exception_class(message) |
| 38 |
|
| 39 |
@pytest.mark.parametrize("exception_class, message", [ |
| 40 |
(AssertionError, "Ärgernis"), |
| 41 |
(AssertionError, u"Ärgernis"), |
| 42 |
(RuntimeError, "Übermut"), |
| 43 |
(RuntimeError, u"Übermut"), |
| 44 |
]) |
| 45 |
def test_issue(exception_class, message): |
| 46 |
with pytest.raises(exception_class) as e: |
| 47 |
# runner.run() |
| 48 |
raise_exception(exception_class, message) |
| 49 |
|
| 50 |
# -- SHOULD NOT RAISE EXCEPTION HERE: |
| •51 |
text = _text(e.value) |
| 52 |
# -- DIAGNOSTICS: |
| 53 |
print(u"text"+ text) |
| 54 |
print(u"exception: %s" % e) |