Skip to content

Commit 968b6af

Browse files
committed
refactor: Update tests
- Regenerated tests with REGEN_TEST_FIXTURES - Updated tests to proper import internal code - Added testing Ci check for Github Signed-off-by: Helio Chissini de Castro <[email protected]>
1 parent 85abf2e commit 968b6af

29 files changed

+738
-1093
lines changed

.github/workflows/docs-ci.yml

+10-16
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,24 @@ jobs:
66
build:
77
runs-on: ubuntu-20.04
88

9-
strategy:
10-
max-parallel: 4
11-
matrix:
12-
python-version: [3.9]
13-
149
steps:
15-
- name: Checkout code
16-
uses: actions/checkout@v3
17-
18-
- name: Setup uv
10+
- uses: actions/checkout@v4
11+
- name: Install uv and set up Python
1912
uses: astral-sh/setup-uv@22695119d769bdb6f7032ad67b9bca0ef8c4a174 # v5.4.0
2013
with:
14+
version: "latest"
15+
pyproject-file: "pyrpoject.toml"
2116
enable-cache: true
22-
pyproject-file: "pyproject.toml"
2317

2418
- name: Install Dependencies
25-
run: pip install -e .[docs]
19+
run: |
20+
uv sync --all-groups
2621
2722
- name: Check Sphinx Documentation build minimally
2823
working-directory: ./docs
29-
run: sphinx-build -E -W source build
24+
run: |
25+
uv run sphinx-build -E -W source build
3026
3127
- name: Check for documentation style errors
32-
working-directory: ./docs
33-
run: ./scripts/doc8_style_check.sh
34-
35-
28+
run: |
29+
uv run hatch run validate-docs

.github/workflows/testing.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Run Pytest with Astral Uv
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Install uv and set up Python ${{ matrix.python-version }}
17+
uses: astral-sh/setup-uv@22695119d769bdb6f7032ad67b9bca0ef8c4a174 # v5.4.0
18+
with:
19+
enable-cache: true
20+
python-version: ${{ matrix.python-version }}
21+
- name: Install dependencies
22+
run: |
23+
uv sync --group=test
24+
- name: Run Pytest
25+
run: |
26+
uv run pytest -vvs

etc/scripts/__init__.py

Whitespace-only changes.

etc/scripts/test_utils_pip_compatibility_tags.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
import pytest
3232

33-
import utils_pip_compatibility_tags
33+
from python_inspector import utils_pip_compatibility_tags
3434

3535

3636
@pytest.mark.parametrize(

etc/scripts/test_utils_pypi_supported_tags.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import pytest
1414

15-
from utils_pypi_supported_tags import validate_platforms_for_pypi
15+
from python_inspector.utils_pypi_supported_tags import validate_platforms_for_pypi
1616

1717
"""
1818
Wheel platform checking tests
@@ -28,7 +28,7 @@ def validate_wheel_filename_for_pypi(filename):
2828
with supported platform tags. Return a list of unsupported platform tags or
2929
an empty list if all tags are supported.
3030
"""
31-
from utils_thirdparty import Wheel
31+
from .utils_thirdparty import Wheel
3232

3333
wheel = Wheel.from_filename(filename)
3434
return validate_platforms_for_pypi(wheel.platforms)

etc/scripts/utils_pip_compatibility_tags.py

+20-22
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,23 @@
3434
interpreter_name,
3535
interpreter_version,
3636
mac_platforms,
37+
Tag,
3738
)
3839

40+
from typing import List, Optional, Tuple
41+
42+
# Define PythonVersion as a type alias for a tuple of integers
43+
PythonVersion = Tuple[int, ...]
44+
3945
_osx_arch_pat = re.compile(r"(.+)_(\d+)_(\d+)_(.+)")
4046

4147

42-
def version_info_to_nodot(version_info):
43-
# type: (Tuple[int, ...]) -> str
48+
def version_info_to_nodot(version_info: Tuple[int]) -> str:
4449
# Only use up to the first two numbers.
4550
return "".join(map(str, version_info[:2]))
4651

4752

48-
def _mac_platforms(arch):
49-
# type: (str) -> List[str]
53+
def _mac_platforms(arch: str) -> List[str]:
5054
match = _osx_arch_pat.match(arch)
5155
if match:
5256
name, major, minor, actual_arch = match.groups()
@@ -66,8 +70,7 @@ def _mac_platforms(arch):
6670
return arches
6771

6872

69-
def _custom_manylinux_platforms(arch):
70-
# type: (str) -> List[str]
73+
def _custom_manylinux_platforms(arch: str) -> List[str]:
7174
arches = [arch]
7275
arch_prefix, arch_sep, arch_suffix = arch.partition("_")
7376
if arch_prefix == "manylinux2014":
@@ -88,8 +91,7 @@ def _custom_manylinux_platforms(arch):
8891
return arches
8992

9093

91-
def _get_custom_platforms(arch):
92-
# type: (str) -> List[str]
94+
def _get_custom_platforms(arch: str) -> List[str]:
9395
arch_prefix, _arch_sep, _arch_suffix = arch.partition("_")
9496
if arch.startswith("macosx"):
9597
arches = _mac_platforms(arch)
@@ -100,8 +102,7 @@ def _get_custom_platforms(arch):
100102
return arches
101103

102104

103-
def _expand_allowed_platforms(platforms):
104-
# type: (Optional[List[str]]) -> Optional[List[str]]
105+
def _expand_allowed_platforms(platforms: Optional[List[str]]) -> Optional[List[str]]:
105106
if not platforms:
106107
return None
107108

@@ -118,16 +119,14 @@ def _expand_allowed_platforms(platforms):
118119
return result
119120

120121

121-
def _get_python_version(version):
122-
# type: (str) -> PythonVersion
122+
def _get_python_version(version: str) -> PythonVersion:
123123
if len(version) > 1:
124124
return int(version[0]), int(version[1:])
125125
else:
126126
return (int(version[0]),)
127127

128128

129-
def _get_custom_interpreter(implementation=None, version=None):
130-
# type: (Optional[str], Optional[str]) -> str
129+
def _get_custom_interpreter(implementation: Optional[str] = None, version: Optional[str] = None):
131130
if implementation is None:
132131
implementation = interpreter_name()
133132
if version is None:
@@ -136,12 +135,11 @@ def _get_custom_interpreter(implementation=None, version=None):
136135

137136

138137
def get_supported(
139-
version=None, # type: Optional[str]
140-
platforms=None, # type: Optional[List[str]]
141-
impl=None, # type: Optional[str]
142-
abis=None, # type: Optional[List[str]]
143-
):
144-
# type: (...) -> List[Tag]
138+
version: Optional[str] = None,
139+
platforms: Optional[List[str]] = None,
140+
impl: Optional[str] = None,
141+
abis: Optional[List[str]] =None,
142+
) -> List[Tag]:
145143
"""Return a list of supported tags for each version specified in
146144
`versions`.
147145
@@ -154,9 +152,9 @@ def get_supported(
154152
:param abis: specify a list of abis you want valid
155153
tags for, or None. If None, use the local interpreter abi.
156154
"""
157-
supported = [] # type: List[Tag]
155+
supported: List[Tag] = []
158156

159-
python_version = None # type: Optional[PythonVersion]
157+
python_version: Optional[PythonVersion] = None
160158
if version is not None:
161159
python_version = _get_python_version(version)
162160

etc/scripts/utils_thirdparty.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from packvers import tags as packaging_tags
3232
from packvers import version as packaging_version
3333

34-
import utils_pip_compatibility_tags
34+
from . import utils_pip_compatibility_tags
3535

3636
"""
3737
Utilities to manage Python thirparty libraries source, binaries and metadata in
@@ -1699,8 +1699,12 @@ def fetch_links(self, normalized_name):
16991699
return links
17001700

17011701

1702-
PYPI_PUBLIC_REPO = PypiSimpleRepository(index_url=PYPI_SIMPLE_URL)
1703-
PYPI_SELFHOSTED_REPO = PypiSimpleRepository(index_url=ABOUT_PYPI_SIMPLE_URL)
1702+
PYPI_PUBLIC_REPO = PypiSimpleRepository()
1703+
PYPI_PUBLIC_REPO.index_url = PYPI_SIMPLE_URL
1704+
1705+
PYPI_SELFHOSTED_REPO = PypiSimpleRepository()
1706+
PYPI_SELFHOSTED_REPO.index_url=ABOUT_PYPI_SIMPLE_URL
1707+
17041708
DEFAULT_PYPI_REPOS = PYPI_PUBLIC_REPO, PYPI_SELFHOSTED_REPO
17051709
DEFAULT_PYPI_REPOS_BY_URL = {r.index_url: r for r in DEFAULT_PYPI_REPOS}
17061710

pyproject.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ python-inspector = "python_inspector.resolve_cli:resolve_dependencies"
107107

108108

109109
[tool.pytest.ini_options]
110-
addopts = ["--import-mode=importlib"]
110+
addopts = [
111+
"--import-mode=importlib",
112+
"--strict-markers",
113+
"-rfExXw",
114+
]
111115
log_cli = true
112116
log_cli_level = "INFO"
113117
testpaths = [

tests/__init__.py

Whitespace-only changes.

tests/data/azure-devops.req-310-expected.json

+40-48
Large diffs are not rendered by default.

tests/data/azure-devops.req-312-expected.json

+40-48
Large diffs are not rendered by default.

tests/data/azure-devops.req-313-expected.json

+40-48
Large diffs are not rendered by default.

tests/data/azure-devops.req-38-expected.json renamed to tests/data/azure-devops.req-39-expected.json

+89-101
Large diffs are not rendered by default.

tests/data/default-url-expected.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"options": [
77
"--json <file>",
88
"--operating-system linux",
9-
"--python-version 38",
9+
"--python-version 39",
1010
"--specifier zipp==3.8.0",
1111
"--use-pypi-json-api"
1212
],

tests/data/frozen-requirements.txt-expected.json

+26-26
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)