def _get_meta_data(raw): meta = {} for item in META_FIELDS: tmp = re.search(b'%%%? ?(' + make_bytes(item) + b'):([\\w=., -]+)', raw) if tmp: meta[make_unicode_string(tmp.group(1))] = remove_uneccessary_spaces(make_unicode_string(tmp.group(2))) return meta
def test_remove_uneccessary_spaces(self): self.assertEqual(remove_uneccessary_spaces(" test"), "test") self.assertEqual(remove_uneccessary_spaces("blah blah "), "blah blah")
def test_remove_uneccessary_spaces(input_data, expected): assert remove_uneccessary_spaces(input_data) == expected
def test_remove_uneccessary_spaces(self): self.assertEqual(remove_uneccessary_spaces(' test'), 'test') self.assertEqual(remove_uneccessary_spaces('blah blah '), 'blah blah')