diff --git a/tests/conftest.py b/tests/conftest.py index a1a0075..1930057 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -80,11 +80,13 @@ class TestStartupData__Helper: sm_StartTS = datetime.datetime.now() # -------------------------------------------------------------------- + @staticmethod def GetStartTS() -> datetime.datetime: assert type(__class__.sm_StartTS) == datetime.datetime # noqa: E721 return __class__.sm_StartTS # -------------------------------------------------------------------- + @staticmethod def CalcRootDir() -> str: r = os.path.abspath(__file__) r = os.path.dirname(r) @@ -93,6 +95,7 @@ def CalcRootDir() -> str: return r # -------------------------------------------------------------------- + @staticmethod def CalcRootLogDir() -> str: if TestConfigPropNames.TEST_CFG__LOG_DIR in os.environ: resultPath = os.environ[TestConfigPropNames.TEST_CFG__LOG_DIR] @@ -104,6 +107,7 @@ def CalcRootLogDir() -> str: return resultPath # -------------------------------------------------------------------- + @staticmethod def CalcCurrentTestWorkerSignature() -> str: currentPID = os.getpid() assert type(currentPID) == int # noqa: E721 @@ -142,16 +146,19 @@ class TestStartupData: sm_RootLogDir: str = TestStartupData__Helper.CalcRootLogDir() # -------------------------------------------------------------------- + @staticmethod def GetRootDir() -> str: assert type(__class__.sm_RootDir) == str # noqa: E721 return __class__.sm_RootDir # -------------------------------------------------------------------- + @staticmethod def GetRootLogDir() -> str: assert type(__class__.sm_RootLogDir) == str # noqa: E721 return __class__.sm_RootLogDir # -------------------------------------------------------------------- + @staticmethod def GetCurrentTestWorkerSignature() -> str: assert type(__class__.sm_CurrentTestWorkerSignature) == str # noqa: E721 return __class__.sm_CurrentTestWorkerSignature @@ -186,6 +193,7 @@ class TEST_PROCESS_STATS: cTotalWarnings: int = 0 # -------------------------------------------------------------------- + @staticmethod def incrementTotalTestCount() -> None: assert type(__class__.cTotalTests) == int # noqa: E721 assert __class__.cTotalTests >= 0 @@ -195,6 +203,7 @@ def incrementTotalTestCount() -> None: assert __class__.cTotalTests > 0 # -------------------------------------------------------------------- + @staticmethod def incrementNotExecutedTestCount() -> None: assert type(__class__.cNotExecutedTests) == int # noqa: E721 assert __class__.cNotExecutedTests >= 0 @@ -204,6 +213,7 @@ def incrementNotExecutedTestCount() -> None: assert __class__.cNotExecutedTests > 0 # -------------------------------------------------------------------- + @staticmethod def incrementExecutedTestCount() -> int: assert type(__class__.cExecutedTests) == int # noqa: E721 assert __class__.cExecutedTests >= 0 @@ -214,6 +224,7 @@ def incrementExecutedTestCount() -> int: return __class__.cExecutedTests # -------------------------------------------------------------------- + @staticmethod def incrementPassedTestCount() -> None: assert type(__class__.cPassedTests) == int # noqa: E721 assert __class__.cPassedTests >= 0 @@ -223,6 +234,7 @@ def incrementPassedTestCount() -> None: assert __class__.cPassedTests > 0 # -------------------------------------------------------------------- + @staticmethod def incrementFailedTestCount(testID: str, errCount: int) -> None: assert type(testID) == str # noqa: E721 assert type(errCount) == int # noqa: E721 @@ -247,6 +259,7 @@ def incrementFailedTestCount(testID: str, errCount: int) -> None: assert __class__.cTotalErrors > 0 # -------------------------------------------------------------------- + @staticmethod def incrementXFailedTestCount(testID: str, errCount: int) -> None: assert type(testID) == str # noqa: E721 assert type(errCount) == int # noqa: E721 @@ -263,6 +276,7 @@ def incrementXFailedTestCount(testID: str, errCount: int) -> None: assert len(__class__.XFailedTests) == __class__.cXFailedTests # -------------------------------------------------------------------- + @staticmethod def incrementSkippedTestCount() -> None: assert type(__class__.cSkippedTests) == int # noqa: E721 assert __class__.cSkippedTests >= 0 @@ -272,6 +286,7 @@ def incrementSkippedTestCount() -> None: assert __class__.cSkippedTests > 0 # -------------------------------------------------------------------- + @staticmethod def incrementNotXFailedTests(testID: str) -> None: assert type(testID) == str # noqa: E721 assert type(__class__.NotXFailedTests) == list # noqa: E721 @@ -286,6 +301,7 @@ def incrementNotXFailedTests(testID: str) -> None: assert len(__class__.NotXFailedTests) == __class__.cNotXFailedTests # -------------------------------------------------------------------- + @staticmethod def incrementWarningTestCount(testID: str, warningCount: int) -> None: assert type(testID) == str # noqa: E721 assert type(warningCount) == int # noqa: E721 @@ -311,6 +327,7 @@ def incrementWarningTestCount(testID: str, warningCount: int) -> None: assert __class__.cTotalWarnings > 0 # -------------------------------------------------------------------- + @staticmethod def incrementUnexpectedTests() -> None: assert type(__class__.cUnexpectedTests) == int # noqa: E721 assert __class__.cUnexpectedTests >= 0 @@ -320,6 +337,7 @@ def incrementUnexpectedTests() -> None: assert __class__.cUnexpectedTests > 0 # -------------------------------------------------------------------- + @staticmethod def incrementAchtungTestCount(testID: str) -> None: assert type(testID) == str # noqa: E721 assert type(__class__.AchtungTests) == list # noqa: E721 @@ -671,7 +689,7 @@ def pytest_runtest_makereport(item: pytest.Function, call: pytest.CallInfo): class LogWrapper2: - _old_method: any + _old_method: typing.Any _err_counter: typing.Optional[int] _warn_counter: typing.Optional[int] @@ -1089,9 +1107,7 @@ def helper__pytest_configure__logging(config: pytest.Config) -> None: pathlib.Path(log_dir).mkdir(exist_ok=True) - logging_plugin: _pytest.logging.LoggingPlugin = config.pluginmanager.get_plugin( - "logging-plugin" - ) + logging_plugin = config.pluginmanager.get_plugin("logging-plugin") assert logging_plugin is not None assert isinstance(logging_plugin, _pytest.logging.LoggingPlugin) diff --git a/tests/helpers/run_conditions.py b/tests/helpers/run_conditions.py index 11357c3..f847d87 100644 --- a/tests/helpers/run_conditions.py +++ b/tests/helpers/run_conditions.py @@ -7,6 +7,7 @@ class RunConditions: # It is not a test kit! __test__ = False + @staticmethod def skip_if_windows(): if platform.system().lower() == "windows": pytest.skip("This test does not support Windows.") diff --git a/tests/test_os_ops_common.py b/tests/test_os_ops_common.py index aab017c..8e9a0ee 100644 --- a/tests/test_os_ops_common.py +++ b/tests/test_os_ops_common.py @@ -1001,7 +1001,7 @@ def LOCAL_WORKER(os_ops: OsOperations, assert os.path.exists(lock_dir) - def LOG_INFO(template: str, *args: list) -> None: + def LOG_INFO(template: str, *args) -> None: assert type(template) == str # noqa: E721 assert type(args) == tuple # noqa: E721 diff --git a/tests/test_os_ops_remote.py b/tests/test_os_ops_remote.py index a89c08e..0cdcb78 100755 --- a/tests/test_os_ops_remote.py +++ b/tests/test_os_ops_remote.py @@ -33,6 +33,7 @@ def test_rmdirs__try_to_delete_file(self, os_ops: OsOperations): assert os.path.exists(path) assert type(x.value) == ExecUtilException # noqa: E721 + assert type(x.value.description) == str # noqa: E721 assert x.value.description == "Utility exited with non-zero code (20). Error: `cannot remove '" + path + "': it is not a directory`" assert x.value.message.startswith(x.value.description) assert type(x.value.error) == str # noqa: E721