Yelp / Testify

A more pythonic testing framework.
Other
306 stars 67 forks source link

assert_raises() fails with UnicodeDecodeError #218

Closed wting closed 10 years ago

wting commented 10 years ago

The first two cases work as expected, but the third case fails:

#!/usr/bin/env python2
# -*- coding: utf-8 -*-

from testify import TestCase
from testify import assert_raises
from testify import run

class AssertRaises(TestCase):

    def test_passes_with_exception(self):
        with assert_raises(Exception):
            raise Exception

    def test_passes_with_os_error(self):
        with assert_raises(OSError):
            raise OSError

    def test_passes_with_unicode_error(self):
        with assert_raises(UnicodeDecodeError):
            raise UnicodeDecodeError

if __name__ == "__main__":
    run()

The stack trace is also mangled:

$ ./assertions_test.py
..error: AssertRaises.test_passes_with_unicode_error
Traceback (most recent call last):
  File "./assertions_test.py", line 21, in test_passes_with_unicode_error
    raise UnicodeDecodeError
TypeError: function takes exactly 5 arguments (0 given)

E
FAILED.  3 tests / 1 case: 2 passed, 1 failed.  (Total test time 0.00s)
wting commented 10 years ago

Nevermind this is a Python problem.