diff options
author | Benjamin Peterson <benjamin@python.org> | 2015-01-02 09:24:53 -0600 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2015-01-02 09:24:53 -0600 |
commit | 753c6af25838fe8f3e357bc058ddad8ced35e620 (patch) | |
tree | 5cfe14baf53a1d48dbff9e27c6ed2b1242db9da4 /test_six.py | |
parent | d5ca48d0fbfe6e88e432a43dd0ce4e42874a3a30 (diff) | |
parent | 8f481c478b9aac37a907eeb58b5e0804a7f4d1a0 (diff) | |
download | six-git-753c6af25838fe8f3e357bc058ddad8ced35e620.tar.gz |
Merged in timograham/six (pull request #57)
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 d5555e8..2a9ca74 100644 --- a/test_six.py +++ b/test_six.py @@ -1,6 +1,7 @@ import operator import sys import types +import unittest import py @@ -785,3 +786,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() |