Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_rep_partial_no_args_no_kwargs(self):
def check():
return True
pcheck = partial(check)
self.assertTrue(pcheck())
self.assertEqual(rep(pcheck), "check()")
def test_rep_partial_with_kwargs(self):
def check(result=True):
return result
pcheck = partial(check, result=True)
self.assertTrue(pcheck())
self.assertEqual(rep(pcheck), "check(result=True)")
def test_rep_string(self):
self.assertEqual(rep("string"), "string")
def test_rep_callable_class(self):
class Check(object):
def __init__(self, result):
self.result = result
def __call__(self):
return self.result
def __repr__(self):
return "%s(%r)" % (type(self).__name__, self.result)
ccheck = Check(True)
self.assertTrue(ccheck())
self.assertEqual(rep(ccheck), "Check(True)")
def test_rep_function(self):
def check():
return True
self.assertTrue(check())
self.assertEqual(rep(check), "check")
def test_rep_partial_with_args(self):
def check(result):
return result
pcheck = partial(check, True)
self.assertTrue(pcheck())
self.assertEqual(rep(pcheck), "check(True)")
def test_rep_partial_with_args_and_kwargs(self):
def check(result, doublecheck=True):
return result == doublecheck
pcheck = partial(check, True, doublecheck=True)
self.assertTrue(pcheck())
self.assertEqual(rep(pcheck), "check(True, doublecheck=True)")