def test_sampleregexp_correct_indexed_key(self): rd = SampleRegexp(os.path.join("(?P<SM>[A-Za-z0-9]+)", "(?:[A-Z0-9]+)_(?P<PU2>[0-9]+)_(?P<PU1>[0-9]+)")) self.assertEqual(rd.fmt, "{SM}/{PU2}_{PU1}") rd.parse("BAR/FOO_007_1") self.assertDictEqual(rd, {'PATH': 'BAR', 'PU': '1_007', 'PU2': '007', 'PU1': '1', 'SM' : 'BAR'})
def test_sampleregexp_parse_unable(self): rd = SampleRegexp("(?:[A-Z0-9]+)_(?P<SM>[A-Za-z0-9]+)") self.assertDictEqual(rd.parse("bar/foo_007"), {})