Skip to content

Commit

Permalink
Make other tests mypy-compliant
Browse files Browse the repository at this point in the history
Signed-off-by: Carmen Bianca BAKKER <carmenbianca@fsfe.org>
  • Loading branch information
carmenbianca committed Apr 9, 2023
1 parent fb53e41 commit 0953d99
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
7 changes: 4 additions & 3 deletions tests/test_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import shutil
import sys
from importlib import import_module

import pytest

Expand All @@ -23,14 +24,14 @@
from reuse.report import ProjectReport

try:
import posix as is_posix
IS_POSIX = bool(import_module("posix"))
except ImportError:
is_posix = False
IS_POSIX = False

cpython = pytest.mark.skipif(
sys.implementation.name != "cpython", reason="only CPython supported"
)
posix = pytest.mark.skipif(not is_posix, reason="Windows not supported")
posix = pytest.mark.skipif(not IS_POSIX, reason="Windows not supported")


# REUSE-IgnoreStart
Expand Down
10 changes: 7 additions & 3 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import re
from inspect import cleandoc
from pathlib import Path
from typing import Optional
from typing import Generator, Optional
from unittest.mock import create_autospec
from urllib.error import URLError

Expand All @@ -29,7 +29,9 @@


@pytest.fixture(params=[True, False])
def optional_git_exe(request, monkeypatch) -> Optional[str]:
def optional_git_exe(
request, monkeypatch
) -> Generator[Optional[str], None, None]:
"""Run the test with or without git."""
exe = GIT_EXE if request.param else ""
monkeypatch.setattr("reuse.project.GIT_EXE", exe)
Expand All @@ -38,7 +40,9 @@ def optional_git_exe(request, monkeypatch) -> Optional[str]:


@pytest.fixture(params=[True, False])
def optional_hg_exe(request, monkeypatch) -> Optional[str]:
def optional_hg_exe(
request, monkeypatch
) -> Generator[Optional[str], None, None]:
"""Run the test with or without mercurial."""
exe = HG_EXE if request.param else ""
monkeypatch.setattr("reuse.project.HG_EXE", exe)
Expand Down
7 changes: 4 additions & 3 deletions tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import os
import shutil
from importlib import import_module
from inspect import cleandoc
from pathlib import Path
from textwrap import dedent
Expand All @@ -18,11 +19,11 @@
from reuse.project import Project

try:
import posix as is_posix
IS_POSIX = bool(import_module("posix"))
except ImportError:
is_posix = False
IS_POSIX = False

posix = pytest.mark.skipif(not is_posix, reason="Windows not supported")
posix = pytest.mark.skipif(not IS_POSIX, reason="Windows not supported")

TESTS_DIRECTORY = Path(__file__).parent.resolve()
RESOURCES_DIRECTORY = TESTS_DIRECTORY / "resources"
Expand Down
7 changes: 4 additions & 3 deletions tests/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,22 @@

import os
import sys
from importlib import import_module

import pytest

from reuse.project import Project
from reuse.report import FileReport, ProjectReport

try:
import posix as is_posix
IS_POSIX = bool(import_module("posix"))
except ImportError:
is_posix = False
IS_POSIX = False

cpython = pytest.mark.skipif(
sys.implementation.name != "cpython", reason="only CPython supported"
)
posix = pytest.mark.skipif(not is_posix, reason="Windows not supported")
posix = pytest.mark.skipif(not IS_POSIX, reason="Windows not supported")


# REUSE-IgnoreStart
Expand Down

0 comments on commit 0953d99

Please sign in to comment.