Skip to content

Commit

Permalink
test_blacklists.py: exclude duplicates across files
Browse files Browse the repository at this point in the history
Also include watched_keywords.txt
  • Loading branch information
tripleee committed Sep 14, 2017
1 parent ac9ae54 commit 7cbbece
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions test/test_blacklists.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,24 @@


def test_blacklist_integrity():
for bl_file in glob('bad_*.txt') + glob('blacklisted_*.txt'):
bl_files = glob('bad_*.txt') + glob('blacklisted_*.txt') + \
['watched_keywords.txt']
seen = dict()
for bl_file in bl_files:
with open(bl_file, 'r') as lines:
seen = dict()
for lineno, line in enumerate(lines, 1):
if line.endswith('\r\n'):
raise(ValueError('{0}:{1}:DOS line ending'.format(bl_file, lineno)))
if not line.endswith('\n'):
raise(ValueError('{0}:{1}:No newline'.format(bl_file, lineno)))
if line == '\n':
raise(ValueError('{0}:{1}:Empty line'.format(bl_file, lineno)))
if bl_file == 'watched_keywords.txt':
line = line.split('\t')[2]
if line in seen:
raise(ValueError('{0}:{1}:Duplicate entry {2} (also on line {3})'.format(
raise(ValueError('{0}:{1}:Duplicate entry {2} (also {3})'.format(
bl_file, lineno, line.rstrip('\n'), seen[line])))
seen[line] = lineno
seen[line] = '{0}:{1}'.format(bl_file, lineno)


def test_blacklist_pull_diff():
Expand Down

0 comments on commit 7cbbece

Please sign in to comment.