|
12 | 12 |
|
13 | 13 |
|
14 | 14 | def get_test_cases(directory):
|
15 |
| - for root, __, files in os.walk(directory): |
| 15 | + for root, _, files in os.walk(directory): |
16 | 16 | for fname in files:
|
17 | 17 | if os.path.splitext(fname)[-1] == ".py":
|
18 | 18 | fullpath = os.path.join(root, fname)
|
19 | 19 | # Use relative path for nice py.test name
|
20 | 20 | relpath = os.path.relpath(fullpath, start=directory)
|
21 |
| - skip_py2 = fname.endswith("_py3.py") |
22 |
| - skip_py3 = fname.endswith("_py2.py") |
23 |
| - |
24 |
| - for py_version_number in (2, 3): |
25 |
| - if py_version_number == 2 and skip_py2: |
26 |
| - continue |
27 |
| - if py_version_number == 3 and skip_py3: |
28 |
| - continue |
29 |
| - py2_arg = ["--py2"] if py_version_number == 2 else [] |
30 |
| - |
31 |
| - yield pytest.param( |
32 |
| - fullpath, |
33 |
| - py2_arg, |
34 |
| - # Manually specify a name for the test |
35 |
| - id="{} - python{}".format(relpath, py_version_number), |
36 |
| - ) |
37 |
| - |
38 |
| - |
39 |
| -@pytest.mark.parametrize("path,py2_arg", get_test_cases(PASS_DIR)) |
40 |
| -def test_success(path, py2_arg): |
41 |
| - stdout, stderr, exitcode = api.run([path] + py2_arg) |
| 21 | + |
| 22 | + yield pytest.param( |
| 23 | + fullpath, |
| 24 | + # Manually specify a name for the test |
| 25 | + id=relpath, |
| 26 | + ) |
| 27 | + |
| 28 | + |
| 29 | +@pytest.mark.parametrize("path", get_test_cases(PASS_DIR)) |
| 30 | +def test_success(path): |
| 31 | + stdout, stderr, exitcode = api.run([path]) |
42 | 32 | assert exitcode == 0, stdout
|
43 | 33 | assert re.match(r"Success: no issues found in \d+ source files?", stdout.strip())
|
44 | 34 |
|
45 | 35 |
|
46 |
| -@pytest.mark.parametrize("path,py2_arg", get_test_cases(FAIL_DIR)) |
47 |
| -def test_fail(path, py2_arg): |
48 |
| - stdout, stderr, exitcode = api.run([path] + py2_arg) |
| 36 | +@pytest.mark.parametrize("path", get_test_cases(FAIL_DIR)) |
| 37 | +def test_fail(path): |
| 38 | + stdout, stderr, exitcode = api.run([path]) |
49 | 39 |
|
50 | 40 | assert exitcode != 0
|
51 | 41 |
|
@@ -80,9 +70,9 @@ def test_fail(path, py2_arg):
|
80 | 70 | pytest.fail(f"Error {repr(errors[lineno])} not found")
|
81 | 71 |
|
82 | 72 |
|
83 |
| -@pytest.mark.parametrize("path,py2_arg", get_test_cases(REVEAL_DIR)) |
84 |
| -def test_reveal(path, py2_arg): |
85 |
| - stdout, stderr, exitcode = api.run([path] + py2_arg) |
| 73 | +@pytest.mark.parametrize("path", get_test_cases(REVEAL_DIR)) |
| 74 | +def test_reveal(path): |
| 75 | + stdout, stderr, exitcode = api.run([path]) |
86 | 76 |
|
87 | 77 | with open(path) as fin:
|
88 | 78 | lines = fin.readlines()
|
|
0 commit comments