From 2c9509f71584c482511874eb4166a044400374e8 Mon Sep 17 00:00:00 2001 From: Prinz23 Date: Mon, 14 May 2018 02:27:45 +0100 Subject: [PATCH] Fix name_parser_tests for test_extra_info_no_name. Add extra test for re lib if regex is installed. Save and restore parser.regex before/after test run (for possible other tests classes). --- CHANGES.md | 7 ++++++- tests/name_parser_tests.py | 42 +++++++++++++++++++++++++------------- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 9bd1834e..57d0bd2e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,9 @@ -### 0.16.6 (2018-05-14 01:00:00 UTC) +### 0.16.7 (2018-05-14 02:40:00 UTC) + +* Fix name_parser_tests for test_extra_info_no_name + + +### 0.16.6 (2018-05-14 01:00:00 UTC) * Change improve tolerance to parse a release title with a badly placed episode name * Change improve handling tvdb_api data when adding upcoming shows with unfilled data diff --git a/tests/name_parser_tests.py b/tests/name_parser_tests.py index 8270dcb0..f8405266 100644 --- a/tests/name_parser_tests.py +++ b/tests/name_parser_tests.py @@ -374,13 +374,13 @@ extra_info_no_name_tests = [('The Show Name', [('Episode 302', 3, 2)], 'The.Show.Name.S03E02E03.720p.AMZN.WEBRip.DDP5.1.x264-GROUP', '720p.AMZN.WEBRip.DDP5.1.x264'), ('The Show Name', [('Episode 302', 3, 2), ('Name 2', 3, 3)], - 'The.Show.Name.S03E02E03.Episode.302.Name2.720p.AMZN.WEBRip.DDP5.1.x264-GROUP', + 'The.Show.Name.S03E02E03.Episode.302.Name.2.720p.AMZN.WEBRip.DDP5.1.x264-GROUP', '720p.AMZN.WEBRip.DDP5.1.x264'), ('The Show Name', [('Episode 302', 3, 2), ('Name 2', 3, 3)], - 'The.Show.Name.S03E02E03.REPACK.Episode.302.Name2.720p.AMZN.WEBRip.DDP5.1.x264-GROUP', + 'The.Show.Name.S03E02E03.REPACK.Episode.302.Name.2.720p.AMZN.WEBRip.DDP5.1.x264-GROUP', 'REPACK.720p.AMZN.WEBRip.DDP5.1.x264'), ('The Show Name', [('Episode 302', 3, 2), ('Name 2', 3, 3)], - 'The.Show.Name.S03E02E03.Episode.302.Name2.REPACK.720p.AMZN.WEBRip.DDP5.1.x264-GROUP', + 'The.Show.Name.S03E02E03.Episode.302.Name.2.REPACK.720p.AMZN.WEBRip.DDP5.1.x264-GROUP', 'REPACK.720p.AMZN.WEBRip.DDP5.1.x264'), ] @@ -656,20 +656,34 @@ class TVEpisode(tv.TVEpisode): class ExtraInfoNoNameTests(test.SickbeardTestDBCase): + def setUp(self): + super(ExtraInfoNoNameTests, self).setUp() + self.oldregex = parser.regex + + def tearDown(self): + super(ExtraInfoNoNameTests, self).tearDown() + parser.regex = self.oldregex + def test_extra_info_no_name(self): - for case in extra_info_no_name_tests: - tvs = TVShow(False, case[0], 2, 1) - for e in case[1]: - tvs.episodes.setdefault(e[1], {}).update({e[2]: TVEpisode(e[0])}) + for i in range(2): + if 1 == i: + if None is parser.regex: + # only retest if regex lib is installed, now test re lib + continue + parser.regex = None + for case in extra_info_no_name_tests: + tvs = TVShow(False, case[0], 2, 1) + for e in case[1]: + tvs.episodes.setdefault(e[1], {}).update({e[2]: TVEpisode(e[0])}) - sickbeard.showList = [tvs] - name_cache.nameCache = {} - name_cache.buildNameCache() + sickbeard.showList = [tvs] + name_cache.nameCache = {} + name_cache.buildNameCache() - np = parser.NameParser() - r = np.parse(case[2]) - n_ep = r.extra_info_no_name() - self.assertEqual(n_ep, case[3]) + np = parser.NameParser() + r = np.parse(case[2], cache_result=False) + n_ep = r.extra_info_no_name() + self.assertEqual(n_ep, case[3]) if __name__ == '__main__':