From dabc7b5e80d76720f266394d9ef434a90564169a Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Wed, 25 Feb 2026 13:35:26 +0300 Subject: [PATCH] conftest is updated (copy from testgres) --- tests/conftest.py | 184 +++++++++++++++++++++++----------------------- 1 file changed, 92 insertions(+), 92 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 1930057..a1adc15 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -82,7 +82,7 @@ class TestStartupData__Helper: # -------------------------------------------------------------------- @staticmethod def GetStartTS() -> datetime.datetime: - assert type(__class__.sm_StartTS) == datetime.datetime # noqa: E721 + assert type(__class__.sm_StartTS) is datetime.datetime return __class__.sm_StartTS # -------------------------------------------------------------------- @@ -103,17 +103,17 @@ def CalcRootLogDir() -> str: rootDir = __class__.CalcRootDir() resultPath = os.path.join(rootDir, "logs") - assert type(resultPath) == str # noqa: E721 + assert type(resultPath) is str return resultPath # -------------------------------------------------------------------- @staticmethod def CalcCurrentTestWorkerSignature() -> str: currentPID = os.getpid() - assert type(currentPID) == int # noqa: E721 + assert type(currentPID) is int startTS = __class__.sm_StartTS - assert type(startTS) == datetime.datetime # noqa: E721 + assert type(startTS) is datetime.datetime result = "pytest-{0:04d}{1:02d}{2:02d}_{3:02d}{4:02d}{5:02d}".format( startTS.year, @@ -148,19 +148,19 @@ class TestStartupData: # -------------------------------------------------------------------- @staticmethod def GetRootDir() -> str: - assert type(__class__.sm_RootDir) == str # noqa: E721 + assert type(__class__.sm_RootDir) is str return __class__.sm_RootDir # -------------------------------------------------------------------- @staticmethod def GetRootLogDir() -> str: - assert type(__class__.sm_RootLogDir) == str # noqa: E721 + assert type(__class__.sm_RootLogDir) is str return __class__.sm_RootLogDir # -------------------------------------------------------------------- @staticmethod def GetCurrentTestWorkerSignature() -> str: - assert type(__class__.sm_CurrentTestWorkerSignature) == str # noqa: E721 + assert type(__class__.sm_CurrentTestWorkerSignature) is str return __class__.sm_CurrentTestWorkerSignature @@ -195,7 +195,7 @@ class TEST_PROCESS_STATS: # -------------------------------------------------------------------- @staticmethod def incrementTotalTestCount() -> None: - assert type(__class__.cTotalTests) == int # noqa: E721 + assert type(__class__.cTotalTests) is int assert __class__.cTotalTests >= 0 __class__.cTotalTests += 1 @@ -205,7 +205,7 @@ def incrementTotalTestCount() -> None: # -------------------------------------------------------------------- @staticmethod def incrementNotExecutedTestCount() -> None: - assert type(__class__.cNotExecutedTests) == int # noqa: E721 + assert type(__class__.cNotExecutedTests) is int assert __class__.cNotExecutedTests >= 0 __class__.cNotExecutedTests += 1 @@ -215,7 +215,7 @@ def incrementNotExecutedTestCount() -> None: # -------------------------------------------------------------------- @staticmethod def incrementExecutedTestCount() -> int: - assert type(__class__.cExecutedTests) == int # noqa: E721 + assert type(__class__.cExecutedTests) is int assert __class__.cExecutedTests >= 0 __class__.cExecutedTests += 1 @@ -226,7 +226,7 @@ def incrementExecutedTestCount() -> int: # -------------------------------------------------------------------- @staticmethod def incrementPassedTestCount() -> None: - assert type(__class__.cPassedTests) == int # noqa: E721 + assert type(__class__.cPassedTests) is int assert __class__.cPassedTests >= 0 __class__.cPassedTests += 1 @@ -236,11 +236,11 @@ def incrementPassedTestCount() -> None: # -------------------------------------------------------------------- @staticmethod def incrementFailedTestCount(testID: str, errCount: int) -> None: - assert type(testID) == str # noqa: E721 - assert type(errCount) == int # noqa: E721 + assert type(testID) is str + assert type(errCount) is int assert errCount > 0 - assert type(__class__.FailedTests) == list # noqa: E721 - assert type(__class__.cFailedTests) == int # noqa: E721 + assert type(__class__.FailedTests) is list + assert type(__class__.cFailedTests) is int assert __class__.cFailedTests >= 0 __class__.FailedTests.append((testID, errCount)) # raise? @@ -251,7 +251,7 @@ def incrementFailedTestCount(testID: str, errCount: int) -> None: assert len(__class__.FailedTests) == __class__.cFailedTests # -------- - assert type(__class__.cTotalErrors) == int # noqa: E721 + assert type(__class__.cTotalErrors) is int assert __class__.cTotalErrors >= 0 __class__.cTotalErrors += errCount @@ -261,11 +261,11 @@ def incrementFailedTestCount(testID: str, errCount: int) -> None: # -------------------------------------------------------------------- @staticmethod def incrementXFailedTestCount(testID: str, errCount: int) -> None: - assert type(testID) == str # noqa: E721 - assert type(errCount) == int # noqa: E721 + assert type(testID) is str + assert type(errCount) is int assert errCount >= 0 - assert type(__class__.XFailedTests) == list # noqa: E721 - assert type(__class__.cXFailedTests) == int # noqa: E721 + assert type(__class__.XFailedTests) is list + assert type(__class__.cXFailedTests) is int assert __class__.cXFailedTests >= 0 __class__.XFailedTests.append((testID, errCount)) # raise? @@ -278,7 +278,7 @@ def incrementXFailedTestCount(testID: str, errCount: int) -> None: # -------------------------------------------------------------------- @staticmethod def incrementSkippedTestCount() -> None: - assert type(__class__.cSkippedTests) == int # noqa: E721 + assert type(__class__.cSkippedTests) is int assert __class__.cSkippedTests >= 0 __class__.cSkippedTests += 1 @@ -288,9 +288,9 @@ def incrementSkippedTestCount() -> None: # -------------------------------------------------------------------- @staticmethod def incrementNotXFailedTests(testID: str) -> None: - assert type(testID) == str # noqa: E721 - assert type(__class__.NotXFailedTests) == list # noqa: E721 - assert type(__class__.cNotXFailedTests) == int # noqa: E721 + assert type(testID) is str + assert type(__class__.NotXFailedTests) is list + assert type(__class__.cNotXFailedTests) is int assert __class__.cNotXFailedTests >= 0 __class__.NotXFailedTests.append(testID) # raise? @@ -303,12 +303,12 @@ def incrementNotXFailedTests(testID: str) -> None: # -------------------------------------------------------------------- @staticmethod def incrementWarningTestCount(testID: str, warningCount: int) -> None: - assert type(testID) == str # noqa: E721 - assert type(warningCount) == int # noqa: E721 + assert type(testID) is str + assert type(warningCount) is int assert testID != "" assert warningCount > 0 - assert type(__class__.WarningTests) == list # noqa: E721 - assert type(__class__.cWarningTests) == int # noqa: E721 + assert type(__class__.WarningTests) is list + assert type(__class__.cWarningTests) is int assert __class__.cWarningTests >= 0 __class__.WarningTests.append((testID, warningCount)) # raise? @@ -319,7 +319,7 @@ def incrementWarningTestCount(testID: str, warningCount: int) -> None: assert len(__class__.WarningTests) == __class__.cWarningTests # -------- - assert type(__class__.cTotalWarnings) == int # noqa: E721 + assert type(__class__.cTotalWarnings) is int assert __class__.cTotalWarnings >= 0 __class__.cTotalWarnings += warningCount @@ -329,7 +329,7 @@ def incrementWarningTestCount(testID: str, warningCount: int) -> None: # -------------------------------------------------------------------- @staticmethod def incrementUnexpectedTests() -> None: - assert type(__class__.cUnexpectedTests) == int # noqa: E721 + assert type(__class__.cUnexpectedTests) is int assert __class__.cUnexpectedTests >= 0 __class__.cUnexpectedTests += 1 @@ -339,9 +339,9 @@ def incrementUnexpectedTests() -> None: # -------------------------------------------------------------------- @staticmethod def incrementAchtungTestCount(testID: str) -> None: - assert type(testID) == str # noqa: E721 - assert type(__class__.AchtungTests) == list # noqa: E721 - assert type(__class__.cAchtungTests) == int # noqa: E721 + assert type(testID) is str + assert type(__class__.AchtungTests) is list + assert type(__class__.cAchtungTests) is int assert __class__.cAchtungTests >= 0 __class__.AchtungTests.append(testID) # raise? @@ -405,8 +405,8 @@ def helper__makereport__setup( assert outcome is not None # it may be pytest.Function or _pytest.unittest.TestCaseFunction assert isinstance(item, pytest.Function) - assert type(call) == pytest.CallInfo # noqa: E721 - assert type(outcome) == T_PLUGGY_RESULT # noqa: E721 + assert type(call) is pytest.CallInfo + assert type(outcome) is T_PLUGGY_RESULT C_LINE1 = "******************************************************" @@ -416,7 +416,7 @@ def helper__makereport__setup( rep: pytest.TestReport = outcome.get_result() assert rep is not None - assert type(rep) == pytest.TestReport # noqa: E721 + assert type(rep) is pytest.TestReport if rep.outcome == "skipped": TEST_PROCESS_STATS.incrementNotExecutedTestCount() @@ -474,29 +474,29 @@ def helper__makereport__call( assert outcome is not None # it may be pytest.Function or _pytest.unittest.TestCaseFunction assert isinstance(item, pytest.Function) - assert type(call) == pytest.CallInfo # noqa: E721 - assert type(outcome) == T_PLUGGY_RESULT # noqa: E721 + assert type(call) is pytest.CallInfo + assert type(outcome) is T_PLUGGY_RESULT # -------- item_error_msg_count1 = item.stash.get(g_error_msg_count_key, 0) - assert type(item_error_msg_count1) == int # noqa: E721 + assert type(item_error_msg_count1) is int assert item_error_msg_count1 >= 0 item_error_msg_count2 = item.stash.get(g_critical_msg_count_key, 0) - assert type(item_error_msg_count2) == int # noqa: E721 + assert type(item_error_msg_count2) is int assert item_error_msg_count2 >= 0 item_error_msg_count = item_error_msg_count1 + item_error_msg_count2 # -------- item_warning_msg_count = item.stash.get(g_warning_msg_count_key, 0) - assert type(item_warning_msg_count) == int # noqa: E721 + assert type(item_warning_msg_count) is int assert item_warning_msg_count >= 0 # -------- rep = outcome.get_result() assert rep is not None - assert type(rep) == pytest.TestReport # noqa: E721 + assert type(rep) is pytest.TestReport # -------- testID = helper__build_test_id(item) @@ -505,12 +505,12 @@ def helper__makereport__call( assert call.start <= call.stop startDT = datetime.datetime.fromtimestamp(call.start) - assert type(startDT) == datetime.datetime # noqa: E721 + assert type(startDT) is datetime.datetime stopDT = datetime.datetime.fromtimestamp(call.stop) - assert type(stopDT) == datetime.datetime # noqa: E721 + assert type(stopDT) is datetime.datetime testDurration = stopDT - startDT - assert type(testDurration) == datetime.timedelta # noqa: E721 + assert type(testDurration) is datetime.timedelta # -------- exitStatus = None @@ -519,7 +519,7 @@ def helper__makereport__call( assert call.excinfo is not None # research assert call.excinfo.value is not None # research - if type(call.excinfo.value) == _pytest.outcomes.Skipped: # noqa: E721 + if type(call.excinfo.value) is _pytest.outcomes.Skipped: assert not hasattr(rep, "wasxfail") exitStatus = ExitStatusNames.SKIPPED @@ -528,7 +528,7 @@ def helper__makereport__call( TEST_PROCESS_STATS.incrementSkippedTestCount() - elif type(call.excinfo.value) == _pytest.outcomes.XFailed: # noqa: E721 E501 + elif type(call.excinfo.value) is _pytest.outcomes.XFailed: exitStatus = ExitStatusNames.XFAILED reasonText = str(call.excinfo.value) reasonMsgTempl = "XFAIL REASON: {0}" @@ -539,12 +539,12 @@ def helper__makereport__call( exitStatus = ExitStatusNames.XFAILED assert hasattr(rep, "wasxfail") assert rep.wasxfail is not None - assert type(rep.wasxfail) == str # noqa: E721 + assert type(rep.wasxfail) is str reasonText = rep.wasxfail reasonMsgTempl = "XFAIL REASON: {0}" - if type(call.excinfo.value) == SIGNAL_EXCEPTION: # noqa: E721 + if type(call.excinfo.value) is SIGNAL_EXCEPTION: pass else: logging.error(call.excinfo.value) @@ -552,10 +552,10 @@ def helper__makereport__call( TEST_PROCESS_STATS.incrementXFailedTestCount(testID, item_error_msg_count) - assert type(reasonText) == str # noqa: E721 + assert type(reasonText) is str if reasonText != "": - assert type(reasonMsgTempl) == str # noqa: E721 + assert type(reasonMsgTempl) is str logging.info("*") logging.info("* " + reasonMsgTempl.format(reasonText)) @@ -563,7 +563,7 @@ def helper__makereport__call( assert call.excinfo is not None assert call.excinfo.value is not None - if type(call.excinfo.value) == SIGNAL_EXCEPTION: # noqa: E721 + if type(call.excinfo.value) is SIGNAL_EXCEPTION: assert item_error_msg_count > 0 pass else: @@ -578,7 +578,7 @@ def helper__makereport__call( assert call.excinfo is None if hasattr(rep, "wasxfail"): - assert type(rep.wasxfail) == str # noqa: E721 + assert type(rep.wasxfail) is str TEST_PROCESS_STATS.incrementNotXFailedTests(testID) @@ -607,15 +607,15 @@ def helper__makereport__call( # -------- assert exitStatus is not None - assert type(exitStatus) == str # noqa: E721 + assert type(exitStatus) is str if exitStatus == ExitStatusNames.FAILED: assert item_error_msg_count > 0 pass # -------- - assert type(TEST_PROCESS_STATS.cTotalDuration) == datetime.timedelta # noqa: E721 - assert type(testDurration) == datetime.timedelta # noqa: E721 + assert type(TEST_PROCESS_STATS.cTotalDuration) is datetime.timedelta + assert type(testDurration) is datetime.timedelta TEST_PROCESS_STATS.cTotalDuration += testDurration @@ -656,13 +656,13 @@ def pytest_runtest_makereport(item: pytest.Function, call: pytest.CallInfo): assert call is not None # it may be pytest.Function or _pytest.unittest.TestCaseFunction assert isinstance(item, pytest.Function) - assert type(call) == pytest.CallInfo # noqa: E721 + assert type(call) is pytest.CallInfo outcome = yield assert outcome is not None - assert type(outcome) == T_PLUGGY_RESULT # noqa: E721 + assert type(outcome) is T_PLUGGY_RESULT - assert type(call.when) == str # noqa: E721 + assert type(call.when) is str if call.when == "collect": return @@ -751,11 +751,11 @@ def __call__(self, record: logging.LogRecord): assert self._warn_counter is not None assert self._critical_counter is not None - assert type(self._err_counter) == int # noqa: E721 + assert type(self._err_counter) is int assert self._err_counter >= 0 - assert type(self._warn_counter) == int # noqa: E721 + assert type(self._warn_counter) is int assert self._warn_counter >= 0 - assert type(self._critical_counter) == int # noqa: E721 + assert type(self._critical_counter) is int assert self._critical_counter >= 0 r = self._old_method(record) @@ -808,27 +808,27 @@ def pytest_pyfunc_call(pyfuncitem: pytest.Function): try: with LogWrapper2() as logWrapper: - assert type(logWrapper) == LogWrapper2 # noqa: E721 + assert type(logWrapper) is LogWrapper2 assert logWrapper._old_method is not None - assert type(logWrapper._err_counter) == int # noqa: E721 + assert type(logWrapper._err_counter) is int assert logWrapper._err_counter == 0 - assert type(logWrapper._warn_counter) == int # noqa: E721 + assert type(logWrapper._warn_counter) is int assert logWrapper._warn_counter == 0 - assert type(logWrapper._critical_counter) == int # noqa: E721 + assert type(logWrapper._critical_counter) is int assert logWrapper._critical_counter == 0 assert logging.root.handle is logWrapper r = yield assert r is not None - assert type(r) == T_PLUGGY_RESULT # noqa: E721 + assert type(r) is T_PLUGGY_RESULT assert logWrapper._old_method is not None - assert type(logWrapper._err_counter) == int # noqa: E721 + assert type(logWrapper._err_counter) is int assert logWrapper._err_counter >= 0 - assert type(logWrapper._warn_counter) == int # noqa: E721 + assert type(logWrapper._warn_counter) is int assert logWrapper._warn_counter >= 0 - assert type(logWrapper._critical_counter) == int # noqa: E721 + assert type(logWrapper._critical_counter) is int assert logWrapper._critical_counter >= 0 assert logging.root.handle is logWrapper @@ -864,7 +864,7 @@ def helper__calc_W(n: int) -> int: assert n > 0 x = int(math.log10(n)) - assert type(x) == int # noqa: E721 + assert type(x) is int assert x >= 0 x += 1 return x @@ -872,7 +872,7 @@ def helper__calc_W(n: int) -> int: # ------------------------------------------------------------------------ def helper__print_test_list(tests: typing.List[str]) -> None: - assert type(tests) == list # noqa: E721 + assert type(tests) is list assert helper__calc_W(9) == 1 assert helper__calc_W(10) == 2 @@ -891,7 +891,7 @@ def helper__print_test_list(tests: typing.List[str]) -> None: nTest = 0 for t in tests: - assert type(t) == str # noqa: E721 + assert type(t) is str assert t != "" nTest += 1 logging.info(templateLine.format(nTest, t)) @@ -899,7 +899,7 @@ def helper__print_test_list(tests: typing.List[str]) -> None: # ------------------------------------------------------------------------ def helper__print_test_list2(tests: typing.List[T_TUPLE__str_int]) -> None: - assert type(tests) == list # noqa: E721 + assert type(tests) is list assert helper__calc_W(9) == 1 assert helper__calc_W(10) == 2 @@ -918,10 +918,10 @@ def helper__print_test_list2(tests: typing.List[T_TUPLE__str_int]) -> None: nTest = 0 for t in tests: - assert type(t) == tuple # noqa: E721 + assert type(t) is tuple assert len(t) == 2 - assert type(t[0]) == str # noqa: E721 - assert type(t[1]) == int # noqa: E721 + assert type(t[0]) is str + assert type(t[1]) is int assert t[0] != "" assert t[1] >= 0 nTest += 1 @@ -943,7 +943,7 @@ def pytest_sessionfinish(): global g_worker_log_is_created # noqa: F824 assert g_test_process_kind is not None - assert type(g_test_process_kind) == T_TEST_PROCESS_KIND # noqa: E721 + assert type(g_test_process_kind) is T_TEST_PROCESS_KIND if g_test_process_kind == T_TEST_PROCESS_KIND.Master: return @@ -951,30 +951,30 @@ def pytest_sessionfinish(): assert g_test_process_kind == T_TEST_PROCESS_KIND.Worker assert g_test_process_mode is not None - assert type(g_test_process_mode) == T_TEST_PROCESS_MODE # noqa: E721 + assert type(g_test_process_mode) is T_TEST_PROCESS_MODE if g_test_process_mode == T_TEST_PROCESS_MODE.Collect: return assert g_test_process_mode == T_TEST_PROCESS_MODE.ExecTests - assert type(g_worker_log_is_created) == bool # noqa: E721 + assert type(g_worker_log_is_created) is bool assert g_worker_log_is_created C_LINE1 = "---------------------------" def LOCAL__print_line1_with_header(header: str): - assert type(C_LINE1) == str # noqa: E721 - assert type(header) == str # noqa: E721 + assert type(C_LINE1) is str + assert type(header) is str assert header != "" logging.info(C_LINE1 + " [" + header + "]") def LOCAL__print_test_list( header: str, test_count: int, test_list: typing.List[str] ): - assert type(header) == str # noqa: E721 - assert type(test_count) == int # noqa: E721 - assert type(test_list) == list # noqa: E721 + assert type(header) is str + assert type(test_count) is int + assert type(test_list) is list assert header != "" assert test_count >= 0 assert len(test_list) == test_count @@ -988,9 +988,9 @@ def LOCAL__print_test_list( def LOCAL__print_test_list2( header: str, test_count: int, test_list: typing.List[T_TUPLE__str_int] ): - assert type(header) == str # noqa: E721 - assert type(test_count) == int # noqa: E721 - assert type(test_list) == list # noqa: E721 + assert type(header) is str + assert type(test_count) is int + assert type(test_list) is list assert header != "" assert test_count >= 0 assert len(test_list) == test_count @@ -1050,7 +1050,7 @@ def LOCAL__print_test_list2( logging.info(" UNEXPECTED : {0}".format(TEST_PROCESS_STATS.cUnexpectedTests)) logging.info("") - assert type(TEST_PROCESS_STATS.cTotalDuration) == datetime.timedelta # noqa: E721 + assert type(TEST_PROCESS_STATS.cTotalDuration) is datetime.timedelta LOCAL__print_line1_with_header("TIME") logging.info("") @@ -1114,7 +1114,7 @@ def helper__pytest_configure__logging(config: pytest.Config) -> None: log_file_path = os.path.join(log_dir, log_name) assert log_file_path is not None - assert type(log_file_path) == str # noqa: E721 + assert type(log_file_path) is str logging_plugin.set_log_path(log_file_path) return @@ -1136,8 +1136,8 @@ def pytest_configure(config: pytest.Config) -> None: g_test_process_mode = helper__detect_test_process_mode(config) g_test_process_kind = helper__detect_test_process_kind(config) - assert type(g_test_process_kind) == T_TEST_PROCESS_KIND # noqa: E721 - assert type(g_test_process_mode) == T_TEST_PROCESS_MODE # noqa: E721 + assert type(g_test_process_kind) is T_TEST_PROCESS_KIND + assert type(g_test_process_mode) is T_TEST_PROCESS_MODE if g_test_process_kind == T_TEST_PROCESS_KIND.Master: pass