| 408 | ], |
| 409 | ) |
| 410 | def test_exclude_patterns_from_file(tmpdir, lines, expected): |
| 411 | files = ["data/something00.txt", "more/data", "home", " #/wsfoobar", "\tstart/whitespace", "whitespace/end\t"] |
| 412 | |
| 413 | def evaluate(filename): |
| 414 | patterns = [] |
| 415 | with open(filename) as f: |
| 416 | load_exclude_file(f, patterns) |
| 417 | matcher = PatternMatcher(fallback=True) |
| 418 | matcher.add_inclexcl(patterns) |
| 419 | return [path for path in files if matcher.match(path)] |
| 420 | |
| 421 | exclfile = tmpdir.join("exclude.txt") |
| 422 | |
| 423 | with exclfile.open("wt") as fh: |
| 424 | fh.write("\n".join(lines)) |
| 425 | |
| 426 | assert evaluate(str(exclfile)) == (files if expected is None else expected) |
| 427 | |
| 428 | |
| 429 | @pytest.mark.parametrize( |