Skip to content

Commit a4245b1

Browse files
Merge branch 'master' into ci/fix-windows-artifacts-slugification
2 parents d11811e + e29fe48 commit a4245b1

File tree

5 files changed

+22
-5
lines changed

5 files changed

+22
-5
lines changed

.github/workflows/run-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
- name: Test with tox
6868
env:
6969
FORCE_COLOR: 1
70-
PYTEST_CI_ARGS: --cov-report=xml --cov-report=html --junitxml=test_artifacts/test_report.xml --color=yes
70+
PYTEST_CI_ARGS: --cov-report=xml --junitxml=test_artifacts/test_report.xml --color=yes
7171
run: tox ${{ matrix.python-version == '3.6' && '--skip-missing-interpreters=true' || '' }}
7272

7373
- name: Upload coverage reports to Codecov

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ module = [
6868
check_untyped_defs = true
6969

7070
[tool.pytest.ini_options]
71-
addopts = "--verbose --cov-config=pyproject.toml"
71+
addopts = "--verbose --cov-config=pyproject.toml --cov-report=html"
7272

7373
[tool.ruff]
7474
# ruff is less lenient than pylint and does not make any exceptions

tests/base_tester.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import sys
33
from abc import ABC
4+
from pathlib import Path
45
from pprint import pprint
56
from typing import Any, Dict, List
67

@@ -21,6 +22,11 @@
2122
pylint_pytest.checkers.fixture.FILE_NAME_PATTERNS = ("*",)
2223

2324

25+
def get_test_root_path() -> Path:
26+
"""Assumes ``base_tester.py`` is at ``<root>/tests``."""
27+
return Path(__file__).parent
28+
29+
2430
class BasePytestTester(ABC):
2531
CHECKER_CLASS = BaseChecker
2632
IMPACTED_CHECKER_CLASSES: List[BaseChecker] = []
@@ -41,7 +47,10 @@ def run_linter(self, enable_plugin):
4147
# pylint: disable-next=protected-access
4248
target_test_file = sys._getframe(1).f_code.co_name.replace("test_", "", 1)
4349
file_path = os.path.join(
44-
os.getcwd(), "tests", "input", self.MSG_ID, target_test_file + ".py"
50+
get_test_root_path(),
51+
"input",
52+
self.MSG_ID,
53+
target_test_file + ".py",
4554
)
4655

4756
with open(file_path) as fin:

tests/base_tester_test.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import pytest
2-
from base_tester import BasePytestTester
2+
from base_tester import BasePytestTester, get_test_root_path
33

44
# pylint: disable=unused-variable
55

66

7+
def test_get_test_root_path():
8+
assert get_test_root_path().name == "tests"
9+
assert (get_test_root_path() / "input").is_dir()
10+
11+
712
def test_init_subclass_valid_msg_id():
813
some_string = "some_string"
914

tests/input/unused-argument/func_param_as_fixture_arg.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,8 @@ def test_nyfix(narg): # unused-argument
2727

2828
@pytest.mark.parametrize("arg", [1, 2, 3])
2929
def test_narg_is_used_nowhere(myfix, narg):
30-
"""A test function that uses the param through a fixture"""
30+
"""
31+
A test function that does not use its param (``narg``):
32+
Not itself, nor through a fixture (``myfix``).
33+
"""
3134
assert myfix

0 commit comments

Comments
 (0)