Skip to content

Commit

Permalink
pytester: LineMatcher: assert collections.abc.Sequence
Browse files Browse the repository at this point in the history
This can be helpful when passing a set accidentally.
  • Loading branch information
blueyed committed Mar 15, 2019
1 parent 33d4c96 commit cb612cd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog/4931.feature.rst
@@ -0,0 +1 @@
pytester's ``LineMatcher`` asserts that the passed lines are a sequence.
3 changes: 3 additions & 0 deletions src/_pytest/pytester.py
Expand Up @@ -4,6 +4,7 @@
from __future__ import print_function

import codecs
import collections
import gc
import os
import platform
Expand Down Expand Up @@ -1235,6 +1236,8 @@ def _getlines(self, lines2):
lines2 = Source(lines2)
if isinstance(lines2, Source):
lines2 = lines2.strip().lines
else:
assert isinstance(lines2, collections.abc.Sequence)
return lines2

def fnmatch_lines_random(self, lines2):
Expand Down

0 comments on commit cb612cd

Please sign in to comment.