test_regexfilter: Fix the test

* only repeats the preceding regular expression, but in the old test, there was
nothing preceding it. This showed up when tests were executed via `python
setup.py test`:

> .........................................E: 20:54:38,617 /home/wieland/dev/picard/picard/track.__init__:88: Failed to compile regex /*/: nothing to repeat at position 0
> Traceback (most recent call last):
>   File "/home/wieland/dev/picard/picard/track.py", line 86, in __init__
>     regex_search = re.compile(remain, re.IGNORECASE)
>   File "/usr/lib/python3.7/re.py", line 234, in compile
>     return _compile(pattern, flags)
>   File "/usr/lib/python3.7/re.py", line 286, in _compile
>     p = sre_compile.compile(pattern, flags)
>   File "/usr/lib/python3.7/sre_compile.py", line 764, in compile
>     p = sre_parse.parse(p, flags)
>   File "/usr/lib/python3.7/sre_parse.py", line 930, in parse
>     p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
>   File "/usr/lib/python3.7/sre_parse.py", line 426, in _parse_sub
>     not nested and not items))
>   File "/usr/lib/python3.7/sre_parse.py", line 651, in _parse
>     source.tell() - here + len(this))
> re.error: nothing to repeat at position 0

This was swallowed by py.test's behaviour to swallow stdout & stderr if no tests
fail.

Remove `*` from test_regexfilter and add an additional test with `/.*/` to
ensure this works.

The genre filter UI handled this correctly by showing the re.error in the UI.
This commit is contained in:
Wieland Hoffmann
2019-10-08 20:58:54 +02:00
committed by Philipp Wolfer
parent 056bde87e6
commit 47e0b4db0e

View File

@@ -73,7 +73,6 @@ class TagGenreFilterTest(PicardTestCase):
-/r[io]ck$/
-/disco+/
+/discoooo/
+/*/
"""
tag_filter = TagGenreFilter(filters)
@@ -92,6 +91,31 @@ class TagGenreFilterTest(PicardTestCase):
self.assertTrue(tag_filter.skip('xdiscooox'))
self.assertFalse(tag_filter.skip('xdiscoooox'))
def test_regex_filter_keep_all(self):
filters = """
-/^j.zz/
-/r[io]ck$/
-/disco+/
+/discoooo/
+/.*/
"""
tag_filter = TagGenreFilter(filters)
self.assertFalse(tag_filter.skip('jazz'))
self.assertFalse(tag_filter.skip('jizz'))
self.assertFalse(tag_filter.skip('jazz blues'))
self.assertFalse(tag_filter.skip('blues jazz'))
self.assertFalse(tag_filter.skip('rock'))
self.assertFalse(tag_filter.skip('blues rock'))
self.assertFalse(tag_filter.skip('blues rick'))
self.assertFalse(tag_filter.skip('rock blues'))
self.assertFalse(tag_filter.skip('disco'))
self.assertFalse(tag_filter.skip('xdiscox'))
self.assertFalse(tag_filter.skip('xdiscooox'))
self.assertFalse(tag_filter.skip('xdiscoooox'))
def test_uppercased_filter(self):
filters = """
-JAZZ*