Rename test classes to prevent warning from pytest
• TestResult → ExecutionResult
• TestStats → ExecutionStats
• Update class docstrings
• Update type hints
• Update variable references
(cherry picked from commit 7e9c8ed1e8)
This commit is contained in:
parent
60520e0188
commit
4da291468d
1 changed files with 9 additions and 9 deletions
|
|
@ -76,8 +76,8 @@ class OutputControl:
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class TestResult:
|
class ExecutionResult:
|
||||||
"""Test result data class"""
|
"""Test execution result data class"""
|
||||||
|
|
||||||
name: str
|
name: str
|
||||||
success: bool
|
success: bool
|
||||||
|
|
@ -90,14 +90,14 @@ class TestResult:
|
||||||
self.timestamp = datetime.now().isoformat()
|
self.timestamp = datetime.now().isoformat()
|
||||||
|
|
||||||
|
|
||||||
class TestStats:
|
class ExecutionStats:
|
||||||
"""Test statistics"""
|
"""Test execution statistics"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.results: List[TestResult] = []
|
self.results: List[ExecutionResult] = []
|
||||||
self.start_time = datetime.now()
|
self.start_time = datetime.now()
|
||||||
|
|
||||||
def add_result(self, result: TestResult):
|
def add_result(self, result: ExecutionResult):
|
||||||
self.results.append(result)
|
self.results.append(result)
|
||||||
|
|
||||||
def export_results(self, path: str = "test_results.json"):
|
def export_results(self, path: str = "test_results.json"):
|
||||||
|
|
@ -274,7 +274,7 @@ def create_generate_request_data(
|
||||||
|
|
||||||
|
|
||||||
# Global test statistics
|
# Global test statistics
|
||||||
STATS = TestStats()
|
STATS = ExecutionStats()
|
||||||
|
|
||||||
|
|
||||||
def run_test(func: Callable, name: str) -> None:
|
def run_test(func: Callable, name: str) -> None:
|
||||||
|
|
@ -287,10 +287,10 @@ def run_test(func: Callable, name: str) -> None:
|
||||||
try:
|
try:
|
||||||
func()
|
func()
|
||||||
duration = time.time() - start_time
|
duration = time.time() - start_time
|
||||||
STATS.add_result(TestResult(name, True, duration))
|
STATS.add_result(ExecutionResult(name, True, duration))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
duration = time.time() - start_time
|
duration = time.time() - start_time
|
||||||
STATS.add_result(TestResult(name, False, duration, str(e)))
|
STATS.add_result(ExecutionResult(name, False, duration, str(e)))
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue