コード例 #1
0
 def test_with_nonstr_sequence_arg_values_resolved(self):
     arg = [
         ("partial", partial(int, "79")),
         ("evaluator", Evaluator(int, "97")),
         ("reference", Reference("number"))
     ]
     evaluator = Evaluator(dict, arg)
     self.assertEqual(
         {"partial": 79, "evaluator": 97, "reference": 101},
         evaluator(self._assembler))
コード例 #2
0
 def test_with_dict_keyword_values_resolved(self):
     arg = {
         "partial": partial(int, "79"),
         "evaluator": Evaluator(int, "97"),
         "reference": Reference("number"),
     }
     evaluator = Evaluator(dict, keyword=arg)
     self.assertEqual(
         {"keyword": {"partial": 79, "evaluator": 97, "reference": 101}},
         evaluator(self._assembler))
コード例 #3
0
 def test_with_nonstr_sequence_keyword_values_resolved(self):
     arg = [
         ("partial", partial(int, "79")),
         ("evaluator", Evaluator(int, "97")),
         ("reference", Reference("number"))
     ]
     evaluator = Evaluator(dict, keyword=arg)
     self.assertEqual(
         {"keyword":
             [("partial", 79), ("evaluator", 97), ("reference", 101)]},
         evaluator(self._assembler))
コード例 #4
0
 def test_with_partial_arg(self):
     evaluator = Evaluator(hex, partial(int, "79"))
     self.assertEqual("0x4f", evaluator(None))
コード例 #5
0
 def test_simple_evaluation(self):
     evaluator = Evaluator(int, "1001111", base=2)
     self.assertEqual(79, evaluator(None))
コード例 #6
0
 def test_initialization_support(self):
     evaluator = Evaluator(int)
     evaluator.args.append("1001111")
     evaluator.keywords.update(base=2)
     self.assertEqual(["1001111"], evaluator.args)
     self.assertEqual({"base": 2}, evaluator.keywords)
コード例 #7
0
 def test_accepts_keywords(self):
     evaluator = Evaluator(int, "1001111", base=2)
     self.assertEqual({"base": 2}, evaluator.keywords)
コード例 #8
0
 def test_accepts_args(self):
     evaluator = Evaluator(int, "79")
     self.assertEqual(["79"], evaluator.args)
コード例 #9
0
 def test_accepts_callable_factory(self):
     evaluator = Evaluator(int)
     self.assertTrue(evaluator.factory is int)
コード例 #10
0
 def setUp(self):
     # for InitializationSupportTest
     self._support = Evaluator(object)
コード例 #11
0
 def test_with_reference_keyword(self):
     evaluator = Evaluator(dict, test=Reference("test.dummy.ModuleClass"))
     d = evaluator(self._assembler)
     self.assertEqual(1, len(d))
     self.assertTrue(isinstance(d["test"], dummy.ModuleClass))
     self.assertEqual("test", d["test"].arg)
コード例 #12
0
 def test_with_reference_arg(self):
     evaluator = Evaluator(
         getattr, Reference("test.dummy.ModuleClass"), "arg")
     self.assertEqual("test", evaluator(self._assembler))
コード例 #13
0
 def test_with_evaluator_keyword(self):
     evaluator = Evaluator(dict, number=Evaluator(int, "79"))
     self.assertEqual({"number": 79}, evaluator(None))