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