Skip to content

Commit

Permalink
Merge branch 'master' into drop-eol-python-add-3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Sassoulas authored Nov 11, 2023
2 parents 333be5c + 3cee43d commit fd067e9
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Slugify GITHUB_REPOSITORY
- name: Slugify GITHUB_REPOSITORY (win)
if: ${{ matrix.os == 'windows-latest' }}
run: |
$slug = $env:GITHUB_REPOSITORY -replace '/', '_'
echo "GITHUB_REPOSITORY_SLUG=$slug" | tee -Append $env:GITHUB_ENV
- name: Slugify GITHUB_REPOSITORY (non-win)
if: ${{ matrix.os != 'windows-latest' }}
run: echo "GITHUB_REPOSITORY_SLUG=${GITHUB_REPOSITORY////_}" >> $GITHUB_ENV

- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -51,7 +58,7 @@ jobs:
- name: Test with tox
env:
FORCE_COLOR: 1
PYTEST_CI_ARGS: --cov-report=xml --cov-report=html --junitxml=test_artifacts/test_report.xml --color=yes
PYTEST_CI_ARGS: --cov-report=xml --junitxml=test_artifacts/test_report.xml --color=yes
run: tox --skip-missing-interpreters=true

- name: Upload coverage reports to Codecov
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ module = [
check_untyped_defs = true

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

[tool.ruff]
# ruff is less lenient than pylint and does not make any exceptions
Expand Down
11 changes: 10 additions & 1 deletion tests/base_tester.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys
from abc import ABC
from pathlib import Path
from pprint import pprint
from typing import Any, Dict, List

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


def get_test_root_path() -> Path:
"""Assumes ``base_tester.py`` is at ``<root>/tests``."""
return Path(__file__).parent


class BasePytestTester(ABC):
CHECKER_CLASS = BaseChecker
IMPACTED_CHECKER_CLASSES: List[BaseChecker] = []
Expand All @@ -41,7 +47,10 @@ def run_linter(self, enable_plugin):
# pylint: disable-next=protected-access
target_test_file = sys._getframe(1).f_code.co_name.replace("test_", "", 1)
file_path = os.path.join(
os.getcwd(), "tests", "input", self.MSG_ID, target_test_file + ".py"
get_test_root_path(),
"input",
self.MSG_ID,
target_test_file + ".py",
)

with open(file_path) as fin:
Expand Down
7 changes: 6 additions & 1 deletion tests/base_tester_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import pytest
from base_tester import BasePytestTester
from base_tester import BasePytestTester, get_test_root_path

# pylint: disable=unused-variable


def test_get_test_root_path():
assert get_test_root_path().name == "tests"
assert (get_test_root_path() / "input").is_dir()


def test_init_subclass_valid_msg_id():
some_string = "some_string"

Expand Down
5 changes: 4 additions & 1 deletion tests/input/unused-argument/func_param_as_fixture_arg.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@ def test_nyfix(narg): # unused-argument

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

0 comments on commit fd067e9

Please sign in to comment.