Skip to content

Commit 3e9b578

Browse files
authored
Merge pull request #162 from aboutcode-org/sample-test-conversion
Migrate tests to VERS test schema
2 parents f365e4e + f4d5fc9 commit 3e9b578

43 files changed

Lines changed: 83870 additions & 35101 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/docs-ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ jobs:
99
strategy:
1010
max-parallel: 4
1111
matrix:
12-
python-version: [3.9]
12+
python-version: ["3.10",]
1313

1414
steps:
1515
- name: Checkout code
16-
uses: actions/checkout@v3
16+
uses: actions/checkout@v5
17+
with:
18+
fetch-depth: 0
1719

1820
- name: Set up Python ${{ matrix.python-version }}
1921
uses: actions/setup-python@v4
@@ -30,5 +32,3 @@ jobs:
3032
- name: Check for documentation style errors
3133
working-directory: ./docs
3234
run: ./scripts/doc8_style_check.sh
33-
34-

azure-pipelines.yml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,21 @@
77

88
jobs:
99

10-
- template: etc/ci/azure-posix.yml
11-
parameters:
12-
job_name: ubuntu20_cpython
13-
image_name: ubuntu-20.04
14-
python_versions: ['3.8', '3.9', '3.10', '3.11', '3.12']
15-
test_suites:
16-
all: |
17-
source venv/bin/activate
18-
pytest -n 2 -vvs
19-
2010
- template: etc/ci/azure-posix.yml
2111
parameters:
2212
job_name: ubuntu22_cpython
2313
image_name: ubuntu-22.04
24-
python_versions: ['3.8', '3.9', '3.10', '3.11', '3.12']
14+
python_versions: ['3.9', '3.10', '3.11', '3.12']
2515
test_suites:
2616
all: |
2717
source venv/bin/activate
2818
pytest -n 2 -vvs
2919
3020
- template: etc/ci/azure-posix.yml
3121
parameters:
32-
job_name: macos12_cpython
33-
image_name: macOS-12
34-
python_versions: ['3.8', '3.9', '3.10', '3.11', '3.12']
22+
job_name: ubuntu24_cpython
23+
image_name: ubuntu-24.04
24+
python_versions: ['3.9', '3.10', '3.11', '3.12']
3525
test_suites:
3626
all: |
3727
source venv/bin/activate
@@ -41,23 +31,33 @@ jobs:
4131
parameters:
4232
job_name: macos13_cpython
4333
image_name: macOS-13
44-
python_versions: ['3.8', '3.9', '3.10', '3.11', '3.12']
34+
python_versions: ['3.9', '3.10', '3.11', '3.12']
4535
test_suites:
4636
all: venv/bin/pytest -n 2 -vvs
4737

4838
- template: etc/ci/azure-posix.yml
4939
parameters:
5040
job_name: macos14_cpython_arm64
5141
image_name: macOS-14
52-
python_versions: ['3.8', '3.9', '3.10', '3.11', '3.12']
42+
python_versions: ['3.9', '3.10', '3.11', '3.12']
5343
test_suites:
5444
all: venv/bin/pytest -n 2 -vvs
5545

46+
- template: etc/ci/azure-posix.yml
47+
parameters:
48+
job_name: macos15_cpython
49+
image_name: macOS-15
50+
python_versions: ['3.9', '3.10', '3.11', '3.12']
51+
test_suites:
52+
all: |
53+
source venv/bin/activate
54+
pytest -n 2 -vvs
55+
5656
- template: etc/ci/azure-win.yml
5757
parameters:
5858
job_name: win2019_cpython
5959
image_name: windows-2019
60-
python_versions: ['3.8', '3.9', '3.10', '3.11', '3.12']
60+
python_versions: ['3.9', '3.10', '3.11', '3.12']
6161
test_suites:
6262
all: |
6363
call venv\Scripts\activate.bat
@@ -67,7 +67,7 @@ jobs:
6767
parameters:
6868
job_name: win2022_cpython
6969
image_name: windows-2022
70-
python_versions: ['3.8', '3.9', '3.10', '3.11', '3.12']
70+
python_versions: ['3.9', '3.10', '3.11', '3.12']
7171
test_suites:
7272
all: |
7373
call venv\Scripts\activate.bat

docs/source/contribute/contrib_doc.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ Interspinx
172172
ScanCode toolkit documentation uses `Intersphinx <http://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html>`_
173173
to link to other Sphinx Documentations, to maintain links to other Aboutcode Projects.
174174

175-
To link sections in the same documentation, standart reST labels are used. Refer
176-
`Cross-Referencing <http://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#ref-role>`_ for more information.
175+
To link sections in the same documentation, standard reST labels are used. Refer
176+
`Cross-Referencing <http://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html>`_ for more information.
177177

178178
For example::
179179

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[metadata]
22
name = univers
3+
version = 31.0.0
34
license = Apache-2.0 AND BSD-3-Clause AND MIT
45

56
# description must be on ONE line https://github.com/pypa/setuptools/issues/1390

tests/__init__.py

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
#
2+
# Copyright (c) nexB Inc. and others.
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
# Visit https://aboutcode.org and https://github.com/aboutcode-org/univers for support and download.
6+
7+
from typing import NamedTuple
8+
from typing import Union
9+
10+
11+
class SchemaDrivenVersTest(NamedTuple):
12+
test_type: str
13+
test_group: str
14+
input: dict
15+
expected_output: Union[list, bool]
16+
17+
@classmethod
18+
def from_data(cls, data: dict):
19+
return cls(**data)
20+
21+
def assert_result(self):
22+
assert self.result == self.expected_output
23+
24+
@property
25+
def result(self):
26+
if self.test_type == "equality":
27+
return self.equality()
28+
elif self.test_type == "comparison":
29+
return self.comparison()
30+
elif self.test_type == "containment":
31+
return self.containment()
32+
elif self.test_type == "roundtrip":
33+
return self.roundtrip()
34+
elif self.test_type == "from_native":
35+
return self.from_native()
36+
37+
raise Exception(f"Unknown test_type: {self.test_type}")
38+
39+
def equality(self):
40+
raise NotImplementedError
41+
42+
def comparison(self):
43+
raise NotImplementedError
44+
45+
def containment(self):
46+
raise NotImplementedError
47+
48+
def roundtrip(self):
49+
raise NotImplementedError
50+
51+
def from_native(self):
52+
raise NotImplementedError
53+
54+
@property
55+
def input_scheme(self):
56+
return self.input["input_scheme"]
57+
58+
@property
59+
def input_native_range(self):
60+
return self.input["native_range"]
61+
62+
@property
63+
def input_version1(self):
64+
return self.input["versions"][0]
65+
66+
@property
67+
def input_version2(self):
68+
return self.input["versions"][1]
69+
70+
71+
def get_test_data_comp(scheme, versions, output):
72+
return {
73+
"test_group": "advanced",
74+
"test_type": "comparison",
75+
"input": {
76+
"input_scheme": scheme,
77+
"versions": versions,
78+
},
79+
"expected_output": output,
80+
}
81+
82+
83+
def get_test_data_eq(scheme, versions, output):
84+
return {
85+
"test_group": "advanced",
86+
"test_type": "equality",
87+
"input": {
88+
"input_scheme": scheme,
89+
"versions": versions,
90+
},
91+
"expected_output": output,
92+
}
93+
94+
95+
def get_test_data_containment(vers, version, output):
96+
return {
97+
"test_group": "advanced",
98+
"test_type": "containment",
99+
"input": {
100+
"vers": vers,
101+
"version": version,
102+
},
103+
"expected_output": output,
104+
}
105+
106+
107+
def get_test_data_roundtrip(vers, output):
108+
return {
109+
"test_group": "advanced",
110+
"test_type": "roundtrip",
111+
"input": {
112+
"vers": vers,
113+
},
114+
"expected_output": output,
115+
}
116+
117+
118+
def get_test_data_from_native(native_range, schema, output):
119+
return {
120+
"test_group": "advanced",
121+
"test_type": "from_native",
122+
"input": {
123+
"native_range": native_range,
124+
"scheme": schema,
125+
},
126+
"expected_output": output,
127+
}

0 commit comments

Comments
 (0)