Skip to content

Commit e4dd5bf

Browse files
authored
test: parallel test support and enable in CI (#571)
1 parent 7db2114 commit e4dd5bf

File tree

5 files changed

+30
-34
lines changed

5 files changed

+30
-34
lines changed

Diff for: dev_requirements/test-requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ moto==3.0.2
44
pytest==7.2.1
55
pytest-cov==3.0.0
66
pytest-mock==3.10.0
7-
pytest-xdist==2.5.0
7+
pytest-xdist==3.2.0
88
boto3==1.20.51
99
botocore==1.23.51

Diff for: test/unit/material_providers/test_aws_kms.py

+23-27
Original file line numberDiff line numberDiff line change
@@ -220,36 +220,32 @@ def test_loaded_key_infos():
220220
assert cmp._regional_clients == {}
221221

222222

223-
@pytest.mark.parametrize(
224-
"kwargs",
225-
[
226-
pytest.param(val, id=str(val))
227-
for val in all_possible_combinations_kwargs(
228-
{},
229-
dict(botocore_session=botocore.session.Session()),
230-
dict(grant_tokens=("sdvoaweih", "auwshefiouawh")),
231-
dict(material_description={"asoiufeoia": "soajfijewi"}),
232-
dict(
233-
regional_clients={
234-
"my-region-1": boto3.session.Session().client(
235-
"kms", region_name="not-a-real-region", endpoint_url="https://not-a-real-url"
236-
)
237-
}
238-
),
239-
)
240-
],
241-
)
242-
def test_kms_cmp_values_set(kwargs):
243-
cmp = AwsKmsCryptographicMaterialsProvider(key_id="example_key_id", **kwargs)
223+
def test_kms_cmp_values_set():
224+
# These aren't parametrized to avoid issues with pytest-xdist test mismatches
225+
# due to different session objects per process
226+
for kwargs in all_possible_combinations_kwargs(
227+
{},
228+
dict(botocore_session=botocore.session.Session()),
229+
dict(grant_tokens=("sdvoaweih", "auwshefiouawh")),
230+
dict(material_description={"asoiufeoia": "soajfijewi"}),
231+
dict(
232+
regional_clients={
233+
"my-region-1": boto3.session.Session().client(
234+
"kms", region_name="not-a-real-region", endpoint_url="https://not-a-real-url"
235+
)
236+
}
237+
),
238+
):
239+
cmp = AwsKmsCryptographicMaterialsProvider(key_id="example_key_id", **kwargs)
244240

245-
assert cmp._key_id == "example_key_id"
241+
assert cmp._key_id == "example_key_id"
246242

247-
if "botocore_session" in kwargs:
248-
assert cmp._botocore_session == kwargs["botocore_session"]
243+
if "botocore_session" in kwargs:
244+
assert cmp._botocore_session == kwargs["botocore_session"]
249245

250-
assert cmp._grant_tokens == kwargs.get("grant_tokens", ())
251-
assert cmp._material_description == kwargs.get("material_description", {})
252-
assert cmp._regional_clients == kwargs.get("regional_clients", {})
246+
assert cmp._grant_tokens == kwargs.get("grant_tokens", ())
247+
assert cmp._material_description == kwargs.get("material_description", {})
248+
assert cmp._regional_clients == kwargs.get("regional_clients", {})
253249

254250

255251
def test_add_regional_client_known_region(default_kms_cmp, patch_boto3_session):

Diff for: test/upstream-requirements-py311.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pytest==7.2.1
2323
pytest-cov==3.0.0
2424
pytest-forked==1.6.0
2525
pytest-mock==3.10.0
26-
pytest-xdist==2.5.0
26+
pytest-xdist==3.2.0
2727
python-dateutil==2.8.2
2828
pytz==2022.7.1
2929
requests==2.28.2

Diff for: test/upstream-requirements-py37.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pytest==7.2.1
2525
pytest-cov==3.0.0
2626
pytest-forked==1.6.0
2727
pytest-mock==3.10.0
28-
pytest-xdist==2.5.0
28+
pytest-xdist==3.2.0
2929
python-dateutil==2.8.2
3030
pytz==2022.7.1
3131
requests==2.28.2

Diff for: tox.ini

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ envlist =
4040
# coverage :: Runs code coverage, failing the build if coverage is below the configured threshold
4141

4242
[testenv:base-command]
43-
commands = pytest --basetemp={envtmpdir} -l {posargs}
43+
commands = pytest -n auto --basetemp={envtmpdir} -l {posargs}
4444

4545
[testenv]
4646
passenv =
@@ -226,7 +226,7 @@ commands =
226226

227227
[testenv:flake8-examples]
228228
basepython = {[testenv:flake8]basepython}
229-
deps = {[testenv:flake8]deps}
229+
deps = {[testenv:flake8]deps}
230230
commands =
231231
flake8 \
232232
# Ignore C901 complexity requirements (examples optimize for straightforward readability)
@@ -345,10 +345,10 @@ whitelist_externals = {[testenv:resetdocs]whitelist_externals}
345345
deps =
346346
-rdev_requirements/doc-requirements.txt
347347
-rdev_requirements/linter-requirements.txt
348-
commands =
348+
commands =
349349
{[testenv:resetdocs]commands}
350350
doc8 doc/index.rst doc/lib/ README.rst CHANGELOG.rst
351-
351+
352352

353353
[testenv:readme]
354354
basepython = python3

0 commit comments

Comments
 (0)