Пример #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"}
Пример #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"}
Пример #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"})
Пример #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"}
Пример #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"
        }
Пример #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}
Пример #7
0
 def test_generic(self):
     c = Converter("pants", conv_val, conv_item)
     ct = ConversionTable([c])
     assert ct.convert({'shirt': 42}) == {'shirt': 42}
Пример #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}
Пример #9
0
 def test_generic(self):
     c = Converter("pants", conv_val, conv_item)
     ct = ConversionTable([c])
     assert ct.convert({'shirt':42}) == {'shirt':42}