示例#1
0
	def test_it_matches_length(self):
		self.assertTrue(f.args_match(([1, 2, 3],), [f.LengthOf(3)]))
		self.assertFalse(f.args_match((1,), [f.Callable()]))
示例#2
0
	def test_it_matches_specific_args(self):
		self.assertTrue(f.args_match((3,), (3,)))
		self.assertFalse(f.args_match((3,), (2,)))
示例#3
0
	def test_it_matches_included_pairs(self):
		self.assertTrue(f.args_match((dict(a=1, b=2, c=3),), [f.IncludesPairs(a=1, b=2)]))
		self.assertFalse(f.args_match((dict(a=1, b=2, c=3),), [f.IncludesPairs(a=2, b=2)]))
		self.assertFalse(f.args_match((None,), [f.IncludesPairs(a=2, b=2)]))
		self.assertFalse(f.args_match(([],), [f.IncludesPairs(a=2, b=2)]))
示例#4
0
	def test_it_matches_callable(self):
		self.assertTrue(f.args_match((lambda: 1,), [f.Callable()]))
		self.assertFalse(f.args_match((1,), [f.Callable()]))
示例#5
0
	def test_it_matches_instanceof(self):
		self.assertTrue(f.args_match(('foo',), [f.InstanceOf(str)]))
		self.assertFalse(f.args_match((1,), [f.InstanceOf(str)]))
示例#6
0
	def test_it_matches_contains(self):
		self.assertTrue(f.args_match(([1, 2, 3],), [f.Contains(2)]))
		self.assertFalse(f.args_match(([1, 2, 3],), [f.Contains(4)]))
		self.assertFalse(f.args_match((1,), [f.Contains(str)]))
示例#7
0
	def test_it_matches_subclass(self):
		class Example(str):
			pass
		self.assertTrue(f.args_match((Example,), [f.Subclasses(str)]))
		self.assertFalse(f.args_match((int,), [f.Subclasses(str)]))
示例#8
0
	def test_it_matches_no_arg(self):
		self.assertTrue(f.args_match((), f.NO_ARG))
		self.assertFalse(f.args_match((1,), f.NO_ARG))
		self.assertFalse(f.args_match((1, 2), f.NO_ARG))
示例#9
0
	def test_it_matches_any_arg(self):
		self.assertTrue(f.args_match((1,), [f.ANY_ARG]))
		self.assertFalse(f.args_match((), [f.ANY_ARG]))
		self.assertFalse(f.args_match((1, 2), [f.ANY_ARG]))
示例#10
0
	def test_it_matches_any_args(self):
		self.assertTrue(f.args_match((), f.ANY_ARGS))
		self.assertTrue(f.args_match((1, 2, 3), f.ANY_ARGS))
		self.assertTrue(f.args_match((1, 2, 3), [f.ANY_ARGS]))
示例#11
0
	def test_it_matches_anything(self):
		self.assertTrue(f.args_match((), f.ANYTHING))
		self.assertTrue(f.args_match((1, 2, 3), f.ANYTHING))
		self.assertTrue(f.args_match((1, 2), [f.ANYTHING]))