diff options
author | Tim Graham <timograham@gmail.com> | 2014-11-25 18:22:19 -0500 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2014-11-25 18:22:19 -0500 |
commit | 8f481c478b9aac37a907eeb58b5e0804a7f4d1a0 (patch) | |
tree | 6fe7d231bdb2e40b44671a101a79725cfc6ce2e2 /test_six.py | |
parent | d7c4f2ed2847c1472c0e60f20e25db20e60dc7d7 (diff) | |
download | six-git-8f481c478b9aac37a907eeb58b5e0804a7f4d1a0.tar.gz |
Added unittest aliases.
Diffstat (limited to 'test_six.py')
-rw-r--r-- | test_six.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test_six.py b/test_six.py index b0ccd8d..c023862 100644 --- a/test_six.py +++ b/test_six.py @@ -1,6 +1,7 @@ import operator import sys import types +import unittest import py @@ -773,3 +774,39 @@ def test_add_metaclass(): __slots__ = "__weakref__", MySlotsWeakref = six.add_metaclass(Meta)(MySlotsWeakref) assert type(MySlotsWeakref) is Meta + + +@py.test.mark.skipif("sys.version_info[:2] < (2, 7)") +def test_assertCountEqual(): + class TestAssertCountEqual(unittest.TestCase): + def test(self): + with self.assertRaises(AssertionError): + six.assertCountEqual(self, (1, 2), [3, 4, 5]) + + six.assertCountEqual(self, (1, 2), [2, 1]) + + TestAssertCountEqual('test').test() + + +def test_assertRegex(): + class TestAssertRegex(unittest.TestCase): + def test(self): + with self.assertRaises(AssertionError): + six.assertRegex(self, 'test', r'^a') + + six.assertRegex(self, 'test', r'^t') + + TestAssertRegex('test').test() + + +def test_assertRaisesRegex(): + class TestAssertRaisesRegex(unittest.TestCase): + def test(self): + with six.assertRaisesRegex(self, AssertionError, '^Foo'): + raise AssertionError('Foo') + + with self.assertRaises(AssertionError): + with six.assertRaisesRegex(self, AssertionError, r'^Foo'): + raise AssertionError('Bar') + + TestAssertRaisesRegex('test').test() |