Ensure that *everything* is typed in community.crypto (#917)

* Ensure that *everything* is typed in community.crypto.

* Fix comment.

* Ignore type definitions/imports and AssertionErrors for code coverage.
This commit is contained in:
Felix Fontein
2025-06-09 10:10:19 +02:00
committed by GitHub
parent ec063d8515
commit d83a923325
73 changed files with 494 additions and 317 deletions

View File

@@ -5,6 +5,7 @@
from __future__ import annotations
import base64
import pathlib
import re
import subprocess
@@ -104,7 +105,7 @@ def test_serialize_asn1_string_as_der_invalid_type() -> None:
@pytest.mark.skip() # This is to just to build the test case assertions and shouldn't run normally.
@pytest.mark.parametrize("value, expected", TEST_CASES)
def test_test_cases(value: str, expected: bytes, tmp_path) -> None:
def test_test_cases(value: str, expected: bytes, tmp_path: pathlib.Path) -> None:
test_file = tmp_path / "test.der"
subprocess.run(
["openssl", "asn1parse", "-genstr", value, "-noout", "-out", test_file],

View File

@@ -254,6 +254,6 @@ def test_parse_dn(name: bytes, expected: list[NameAttribute]) -> None:
),
],
)
def test_parse_dn_failure(name: bytes, message: str):
def test_parse_dn_failure(name: bytes, message: str) -> None:
with pytest.raises(OpenSSLObjectError, match=f"^{re.escape(message)}$"):
_parse_dn(name)

View File

@@ -60,7 +60,7 @@ def test_pem_handling(
pems: list[str],
is_pem: bool,
private_key_type: t.Literal["raw", "pkcs1", "pkcs8", "unknown-pem"],
):
) -> None:
assert identify_pem_format(data) == is_pem
assert identify_private_key_format(data) == private_key_type
try: