aboutsummaryrefslogtreecommitdiff
path: root/tests/test_backend_common.py
diff options
context:
space:
mode:
authorDmitrii Agibov <dmitrii.agibov@arm.com>2022-09-08 14:24:39 +0100
committerDmitrii Agibov <dmitrii.agibov@arm.com>2022-09-09 17:21:48 +0100
commitf5b293d0927506c2a979a091bf0d07ecc78fa181 (patch)
tree4de585b7cb6ed34da8237063752270189a730a41 /tests/test_backend_common.py
parentcde0c6ee140bd108849bff40467d8f18ffc332ef (diff)
downloadmlia-f5b293d0927506c2a979a091bf0d07ecc78fa181.tar.gz
MLIA-386 Simplify typing in the source code
- Enable deferred annotations evaluation - Use builtin types for type hints whenever possible - Use | syntax for union types - Rename mlia.core._typing into mlia.core.typing Change-Id: I3f6ffc02fa069c589bdd9e8bddbccd504285427a
Diffstat (limited to 'tests/test_backend_common.py')
-rw-r--r--tests/test_backend_common.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/tests/test_backend_common.py b/tests/test_backend_common.py
index 0533ef6..d11261e 100644
--- a/tests/test_backend_common.py
+++ b/tests/test_backend_common.py
@@ -2,16 +2,14 @@
# SPDX-License-Identifier: Apache-2.0
# pylint: disable=no-self-use,protected-access
"""Tests for the common backend module."""
+from __future__ import annotations
+
from contextlib import ExitStack as does_not_raise
from pathlib import Path
from typing import Any
from typing import cast
-from typing import Dict
from typing import IO
from typing import List
-from typing import Optional
-from typing import Tuple
-from typing import Union
from unittest.mock import MagicMock
import pytest
@@ -62,7 +60,7 @@ def test_load_config(
) -> None:
"""Test load_config."""
with expected_exception:
- configs: List[Optional[Union[Path, IO[bytes]]]] = (
+ configs: list[Path | IO[bytes] | None] = (
[None]
if not filename
else [
@@ -283,8 +281,8 @@ class TestBackend:
def test_resolved_parameters(
self,
class_: type,
- config: Dict,
- expected_output: List[Tuple[Optional[str], Param]],
+ config: dict,
+ expected_output: list[tuple[str | None, Param]],
) -> None:
"""Test command building."""
backend = class_(config)
@@ -343,7 +341,7 @@ class TestBackend:
],
)
def test__parse_raw_parameter(
- self, input_param: str, expected: Tuple[str, Optional[str]]
+ self, input_param: str, expected: tuple[str, str | None]
) -> None:
"""Test internal method of parsing a single raw parameter."""
assert parse_raw_parameter(input_param) == expected
@@ -476,7 +474,7 @@ class TestCommand:
],
],
)
- def test_validate_params(self, params: List[Param], expected_error: Any) -> None:
+ def test_validate_params(self, params: list[Param], expected_error: Any) -> None:
"""Test command validation function."""
with expected_error:
Command([], params)