def test_strip(self): assert importer.strip('') == '' assert importer.strip(None) == '' assert importer.strip(0) == '' assert importer.strip(' ') == '' assert importer.strip(' \t') == '' assert importer.strip('\t ') == '' assert importer.strip(' \n ') == '' assert importer.strip('abc') == 'abc' assert importer.strip('a b\tc ') == 'a b\tc' assert importer.strip(' a b\tc\t') == 'a b\tc'
def test_strip(self): self.assertEqual(importer.strip(""), "") self.assertEqual(importer.strip(None), "") self.assertEqual(importer.strip(0), "") self.assertEqual(importer.strip(" "), "") self.assertEqual(importer.strip(" \t"), "") self.assertEqual(importer.strip("\t "), "") self.assertEqual(importer.strip(" \n "), "") self.assertEqual(importer.strip("abc"), "abc") self.assertEqual(importer.strip("a b\tc "), "a b\tc") self.assertEqual(importer.strip(" a b\tc\t"), "a b\tc")
def maybe_add_required_keys(a_dict, required_keys, dummy_value=u'?'): for required_key in required_keys: if not importer.strip(a_dict.get(required_key)): logging.info('%s is missing from %s; will add dummy value(%s)', required_key, a_dict, dummy_value) a_dict[required_key] = dummy_value return a_dict
def maybe_add_required_keys(a_dict, required_keys, dummy_value=u'?'): for required_key in required_keys: if not importer.strip(a_dict.get(required_key)): logging.info( '%s is missing from %s; will add dummy value(%s)', required_key, a_dict, dummy_value) a_dict[required_key] = dummy_value return a_dict