Exemple #1
0
 def test_single_parameter(self):
     def dup(input_field):
         return input_field + input_field
     filter = m.make_field_adder('2a', dup, ['a'])
     self.assertListEqual(
         [
             ('a', 'b', '2a'),
             ('a', 'b', 'aa'),
             (1.1, 3, 2.2)
         ],
         list(filter([
             ('a', 'b'),
             ('a', 'b'),
             (1.1, 3)
             ])))
Exemple #2
0
 def test_two_parameters(self):
     def plus(input_field1, input_field2):
         return input_field1 + input_field2
     filter = m.make_field_adder('b+a', plus, ['b', 'a'])
     self.assertListEqual(
         [
             ('a', 'b', 'b+a'),
             ('a', 'b', 'ba'),
             (1.1, 3, 4.1)
         ],
         list(filter([
             ('a', 'b'),
             ('a', 'b'),
             (1.1, 3)
             ])))
Exemple #3
0
    def test_no_parameters(self):
        def constant():
            return 'c'

        filter = m.make_field_adder('const', constant, [])
        self.assertListEqual(
            [
                ('a', 'b', 'const'),
                ('a', 'b', 'c'),
                (1.1, 3, 'c')
            ],
            list(filter([
                ('a', 'b'),
                ('a', 'b'),
                (1.1, 3)
                ])))