def test_parse_rules(self): self.assertEqual(parse_rules(''), []) data = dedent('''\ # comment tag::^ERROR$ tag2:project:\\[error\\] ''') self.assertEqual(parse_rules(data), [('tag', '', '^ERROR$'), ('tag2', 'project', r'\[error\]')])
def test_regex_parse_error(self): with self.assertRaisesRegexp(ParseError, 'file.ext, line 1: unexpected end of regular expression'): parse_rules('foo::[x', path='file.ext')
def test_unicode_regexp(self): with self.assertRaisesRegexp(ParseError, 'file.ext, line 1: syntax error'): parse_rules("foo::u'foo'", path='file.ext')
def test_quotes_parse_error_3(self): with self.assertRaisesRegexp(ParseError, 'file.ext, line 1: invalid Python string literal'): parse_rules("foo::'b'ar' \n", path='file.ext')
def test_quotes_parse_error(self): with self.assertRaisesRegexp(ParseError, 'file.ext, line 1: mismatched quotes'): parse_rules('foo::"bar\n', path='file.ext')
def test_parse_error(self): with self.assertRaisesRegexp(ParseError, 'file.ext, line 2: syntax error'): parse_rules('foo::bar\n' 'foo:bar', path='file.ext')
def test_quotes_parse_error_2(self): with self.assertRaisesRegexp( ParseError, 'file.ext, line 1: invalid Python string literal'): parse_rules("foo::bar' \n", path='file.ext')
def test_regex_parse_error(self): with self.assertRaisesRegexp( ParseError, 'file.ext, line 1: unexpected end of regular expression'): parse_rules('foo::[x', path='file.ext')