Esempio n. 1
0
    def test_multi_string_formatter(self):
        sf = StringFormatter("iteration_{i}", i=InputSelector("iters"))
        sfs = sf.evaluate({"iters": [1, 2, 3]})

        self.assertEqual(3, len(sfs))
        self.assertEqual("iteration_1", sfs[0])
        self.assertEqual("iteration_2", sfs[1])
        self.assertEqual("iteration_3", sfs[2])
Esempio n. 2
0
 def test_evaluate_from_input_selector_resolved(self):
     namesel = InputSelector("name")
     adjsel = InputSelector("adjsel")
     b = StringFormatter("{name} is {adjective}",
                         name=namesel,
                         adjective=adjsel)
     inp = {"name": "Janis", "adjsel": "pretty good"}
     self.assertEqual("Janis is pretty good", b.evaluate(inp))
Esempio n. 3
0
    def test_dotproduct_string_formatter(self):
        sf = StringFormatter("iteration_{i}_{j}",
                             i=InputSelector("it1"),
                             j=InputSelector("it2"))
        sfs = sf.evaluate({"it1": [1, 2, 3], "it2": ["a", "b", "c"]})

        self.assertEqual(3, len(sfs))
        self.assertEqual("iteration_1_a", sfs[0])
        self.assertEqual("iteration_2_b", sfs[1])
        self.assertEqual("iteration_3_c", sfs[2])