Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions tests/test_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

from __future__ import annotations

import collections
import itertools
import os
import platform
import sys
from typing import cast
from typing import NamedTuple, cast
from unittest import mock

import pytest
Expand Down Expand Up @@ -110,9 +109,12 @@ def test_allows_prerelease(self) -> None:
)


FakeVersionInfo = collections.namedtuple(
"FakeVersionInfo", ["major", "minor", "micro", "releaselevel", "serial"]
)
class FakeVersionInfo(NamedTuple):
major: int
minor: int
micro: int
releaselevel: str
serial: int


class TestDefaultEnvironment:
Expand Down
10 changes: 7 additions & 3 deletions tests/test_musllinux.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import collections
import pathlib
import subprocess
import typing
Expand All @@ -14,6 +13,11 @@
if typing.TYPE_CHECKING:
from collections.abc import Generator


class Proc(typing.NamedTuple):
stderr: str


MUSL_AMD64 = "musl libc (x86_64)\nVersion 1.2.2\n"
MUSL_I386 = "musl libc (i386)\nVersion 1.2.1\n"
MUSL_AARCH64 = "musl libc (aarch64)\nVersion 1.1.24\n"
Expand Down Expand Up @@ -71,8 +75,8 @@ def test_get_musl_version(
version: _MuslVersion | None,
ld_musl: str | None,
) -> None:
def mock_run(*args: object, **kwargs: object) -> tuple[object, ...]:
return collections.namedtuple("Proc", "stderr")(output)
def mock_run(*args: object, **kwargs: object) -> Proc:
return Proc(stderr=output)

run_recorder = pretend.call_recorder(mock_run)
monkeypatch.setattr(_musllinux.subprocess, "run", run_recorder) # type: ignore[attr-defined]
Expand Down
12 changes: 9 additions & 3 deletions tests/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@
from collections.abc import Callable


class AndroidVer(typing.NamedTuple):
release: str
api_level: int
manufacturer: str
model: str
device: str
is_emulator: bool


@pytest.fixture
def example_tag() -> tags.Tag:
return tags.Tag("py3", "none", "any")
Expand Down Expand Up @@ -89,9 +98,6 @@ def mock_android(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(platform, "system", lambda: "Android")
monkeypatch.setattr(sysconfig, "get_platform", lambda: "android-21-arm64_v8a")

AndroidVer = collections.namedtuple(
"AndroidVer", "release api_level manufacturer model device is_emulator"
)
monkeypatch.setattr(
platform,
"android_ver",
Expand Down