File size: 1,789 Bytes
065fee7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
from __future__ import print_function
import unittest
import wrapt
class TestPartialCallableObjectProxy(unittest.TestCase):
def test_no_arguments(self):
def func0():
return ((), {})
partial0 = wrapt.PartialCallableObjectProxy(func0)
args, kwargs = (), {}
self.assertEqual(partial0(), (args, kwargs))
def test_empty_arguments(self):
def func0(*args, **kwargs):
return (args, kwargs)
args, kwargs = (), {}
partial0 = wrapt.PartialCallableObjectProxy(func0, *args, **kwargs)
self.assertEqual(partial0(), (args, kwargs))
def test_1_positional_argument(self):
def func0(*args, **kwargs):
return (args, kwargs)
args, kwargs = (1,), {}
partial0 = wrapt.PartialCallableObjectProxy(func0, *args)
self.assertEqual(partial0(), (args, kwargs))
def test_1_keyword_argument(self):
def func0(*args, **kwargs):
return (args, kwargs)
args, kwargs = (), {'k1': 1}
partial0 = wrapt.PartialCallableObjectProxy(func0, **kwargs)
self.assertEqual(partial0(), (args, kwargs))
def test_multiple_positional_arguments(self):
def func0(*args, **kwargs):
return (args, kwargs)
args, kwargs = (1, 2, 3), {}
partial0 = wrapt.PartialCallableObjectProxy(func0, *args)
self.assertEqual(partial0(), (args, kwargs))
def test_multiple_keyword_arguments(self):
def func0(*args, **kwargs):
return (args, kwargs)
args, kwargs = (), {'k1': 1, 'k2': 2, 'k3': 3}
partial0 = wrapt.PartialCallableObjectProxy(func0, **kwargs)
self.assertEqual(partial0(), (args, kwargs))
if __name__ == '__main__':
unittest.main()
|