def test_two_variables_four_values(self):
   vals1, vals2 = (1, 2), ("ab", "cd")
   sef = ShortExpressionFinder([('var1', vals1), ('var2', vals2)])
   all_configs = tuple(itertools.product(vals1, vals2))
   for val1 in vals1:
     for val2 in vals2:
       self.assertEqual('var1==%d and var2=="%s"' % (val1, val2),
                        sef.get_expr([(val1, val2)]))
   for val1 in vals1:
     self.assertEqual('var1==%d and (var2=="ab" or var2=="cd")' % val1,
                      sef.get_expr([(val1, "ab"), (val1, "cd")]))
   for val2 in vals2:
     self.assertEqual('(var1==1 or var1==2) and var2=="%s"' % val2,
                      sef.get_expr([(1, val2), (2, val2)]))
   self.assertEqual('(var1==1 or var1==2) and (var2=="ab" or var2=="cd")',
                    sef.get_expr(all_configs))
Exemplo n.º 2
0
 def test_two_variables_four_values(self):
     vals1, vals2 = (1, 2), ("ab", "cd")
     sef = ShortExpressionFinder([('var1', vals1), ('var2', vals2)])
     all_configs = tuple(itertools.product(vals1, vals2))
     for val1 in vals1:
         for val2 in vals2:
             self.assertEqual('var1==%d and var2=="%s"' % (val1, val2),
                              sef.get_expr([(val1, val2)]))
     for val1 in vals1:
         self.assertEqual('var1==%d and (var2=="ab" or var2=="cd")' % val1,
                          sef.get_expr([(val1, "ab"), (val1, "cd")]))
     for val2 in vals2:
         self.assertEqual('(var1==1 or var1==2) and var2=="%s"' % val2,
                          sef.get_expr([(1, val2), (2, val2)]))
     self.assertEqual('(var1==1 or var1==2) and (var2=="ab" or var2=="cd")',
                      sef.get_expr(all_configs))
 def test_simple(self):
   sef = ShortExpressionFinder([('var', [17])])
   self.assertEqual('var==17', sef.get_expr([(17,)]))
Exemplo n.º 4
0
 def test_simple(self):
     sef = ShortExpressionFinder([('var', [17])])
     self.assertEqual('var==17', sef.get_expr([(17, )]))