Sha256: b10f0716ecf4c3af06a3e88196fa2cdf68eba53e4f451ec88b90e3b3ce4e5b1f

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

# -*- coding: UTF-8
"""
Test issue #458:

Traceback (most recent call last):
  File "/usr/local/bin/behave", line 11, in <module>
    sys.exit(main())
  File "/Library/Python/2.7/site-packages/behave/__main__.py", line 123, in main
    print(u"Exception %s: %s" % (e.__class__.__name__, text))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 69: ordinal not in range(128)


    try:
        failed = runner.run()
    except ParserError as e:
        print(u"ParseError: %s" % e)
    except ConfigError as e:
        print(u"ConfigError: %s" % e)
    except FileNotFoundError as e:
        print(u"FileNotFoundError: %s" % e)
    except InvalidFileLocationError as e:
        print(u"InvalidFileLocationError: %s" % e)
    except InvalidFilenameError as e:
        print(u"InvalidFilenameError: %s" % e)
    except Exception as e:
        # -- DIAGNOSTICS:
        text = _text(e)
        print(u"Exception %s: %s" % (e.__class__.__name__, text))
        raise
"""

from behave.textutil import text as _text
import pytest


def raise_exception(exception_class, message):
    raise exception_class(message)

@pytest.mark.parametrize("exception_class, message", [
    (AssertionError, "Ärgernis"),
    (AssertionError, u"Ärgernis"),
    (RuntimeError, "Übermut"),
    (RuntimeError, u"Übermut"),
])
def test_issue(exception_class, message):
    with pytest.raises(exception_class) as e:
        # runner.run()
        raise_exception(exception_class, message)

    # -- SHOULD NOT RAISE EXCEPTION HERE:
    text = _text(e)
    # -- DIAGNOSTICS:
    print(u"text"+ text)
    print(u"exception: %s" % e)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
busser-behave-0.1.3 vendor/behave/tests/issues/test_issue0458.py