Exemplo n.º 1
0
 def test_drop(self):
     ct = ConversionTable([
         ("joe", "I wear {0}".format, conv_item),
         ("frank", "You wear {0}".format, lambda k, v: None)])
     
     ct.generic_item = drop
     
     d = ct.convert({'joe':'pants', 'frank':'shirt', 'bob':'shoes'})
     assert d == {'joe': "I wear pants"}
Exemplo n.º 2
0
    def test_drop(self):
        ct = ConversionTable([
            ("joe", "I wear {0}".format, conv_item),
            ("frank", "You wear {0}".format, lambda k, v: None)])

        ct.generic_item = drop

        d = ct.convert({'joe': 'pants', 'frank': 'shirt', 'bob': 'shoes'})
        assert d == {'joe': "I wear pants"}
Exemplo n.º 3
0
 def test_convert(self):
     ct = ConversionTable([
         ("joe", "I wear {0}".format, conv_item),
         ("frank", "You wear {0}".format, conv_item)])
     
     ct.generic_value = "Someone wears {0}".format
     
     d = ct.convert({'joe':'pants', 'frank':'shirt', 'bob':'shoes'})
     self.assertDictEqual(d, {'joe': "I wear pants", 'frank': "You wear shirt", 'bob': "Someone wears shoes"})
Exemplo n.º 4
0
 def test_convert(self):
     ct = ConversionTable([
         ("joe", "I wear {0}".format, convItem),
         ("frank", "You wear {0}".format, convItem)])
     
     ct.genericValue = "Someone wears {0}".format
     
     d = ct.convert({'joe':'pants', 'frank':'shirt', 'bill': 'naked', 'bob':'shoes'})
     assert d == {'joe': "I wear pants", 'frank': "You wear shirt", 'bob': "Someone wears shoes", 'bill':"naked"}
Exemplo n.º 5
0
    def test_convert(self):
        ct = ConversionTable([("joe", "I wear {0}".format, convItem),
                              ("frank", "You wear {0}".format, convItem)])

        ct.genericValue = "Someone wears {0}".format

        d = ct.convert({
            'joe': 'pants',
            'frank': 'shirt',
            'bill': 'naked',
            'bob': 'shoes'
        })
        assert d == {
            'joe': "I wear pants",
            'frank': "You wear shirt",
            'bob': "Someone wears shoes",
            'bill': "naked"
        }
Exemplo n.º 6
0
 def test_missing(self):
     c = Converter("pants", conv_val, conv_item, True)
     ct = ConversionTable([c])
     with self.assertRaises(ValueError):
         ct.convert({'shirt': 42}) == {'shirt': 42}
Exemplo n.º 7
0
 def test_generic(self):
     c = Converter("pants", conv_val, conv_item)
     ct = ConversionTable([c])
     assert ct.convert({'shirt': 42}) == {'shirt': 42}
Exemplo n.º 8
0
 def test_missing(self):
     c = Converter("pants", conv_val, conv_item, True)
     ct = ConversionTable([c])
     with self.assertRaises(ValueError):
         ct.convert({'shirt':42}) == {'shirt':42}
Exemplo n.º 9
0
 def test_generic(self):
     c = Converter("pants", conv_val, conv_item)
     ct = ConversionTable([c])
     assert ct.convert({'shirt':42}) == {'shirt':42}