The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
GaudiTesting.FixtureResult.FixtureResult Class Reference

Public Member Functions

 __init__ (self, subprocess.CompletedProcess completed_process, datetime start_time, datetime end_time, ProcessTimeoutError|ExceededStreamError|None run_exception, list[str] command, list[str] expanded_command, dict env, str cwd)
 elapsed_time (self)
dict to_dict (self)

Static Public Member Functions

 format_value (value)

Public Attributes

 completed_process = completed_process
 start_time = start_time
 end_time = end_time
 run_exception = run_exception
 command = command
 expanded_command = expanded_command
 runtime_environment = env
 cwd = cwd

Detailed Description

A class to encapsulate the results of a subprocess execution in a test fixture.

Definition at line 29 of file FixtureResult.py.

Constructor & Destructor Documentation

◆ __init__()

GaudiTesting.FixtureResult.FixtureResult.__init__ ( self,
subprocess.CompletedProcess completed_process,
datetime start_time,
datetime end_time,
ProcessTimeoutError | ExceededStreamError | None run_exception,
list[str] command,
list[str] expanded_command,
dict env,
str cwd )

Definition at line 34 of file FixtureResult.py.

44 ):
45 self.completed_process = completed_process
46 self.start_time = start_time
47 self.end_time = end_time
48 self.run_exception = run_exception
49 self.command = command
50 self.expanded_command = expanded_command
51 self.runtime_environment = env
52 self.cwd = cwd
53

Member Function Documentation

◆ elapsed_time()

GaudiTesting.FixtureResult.FixtureResult.elapsed_time ( self)

Definition at line 54 of file FixtureResult.py.

54 def elapsed_time(self):
55 return self.end_time - self.start_time
56

◆ format_value()

GaudiTesting.FixtureResult.FixtureResult.format_value ( value)
static
Format a given value to a string representation.

Definition at line 58 of file FixtureResult.py.

58 def format_value(value):
59 """
60 Format a given value to a string representation.
61 """
62 if isinstance(value, list):
63 return repr(value)
64 elif isinstance(value, dict):
65 return "\n".join(f"{k}={v}" for k, v in value.items())
66 return str(value or "")
67

◆ to_dict()

dict GaudiTesting.FixtureResult.FixtureResult.to_dict ( self)
Convert the attributes of the FixtureResult into a dictionary.

Definition at line 68 of file FixtureResult.py.

68 def to_dict(self) -> dict:
69 """
70 Convert the attributes of the FixtureResult into a dictionary.
71 """
72 properties = {attr: getattr(self, attr) for attr in vars(self)}
73 properties.update(
74 {
75 "stdout": CodeWrapper(
76 self.completed_process.stdout.decode(
77 "utf-8", errors="backslashreplace"
78 ),
79 "console",
80 )
81 if self.completed_process.stdout
82 else None,
83 "stderr": CodeWrapper(
84 self.completed_process.stderr.decode(
85 "utf-8", errors="backslashreplace"
86 ),
87 "console",
88 )
89 if self.completed_process.stderr
90 else None,
91 "return_code": self.completed_process.returncode
92 if self.completed_process.returncode
93 else None,
94 "elapsed_time": self.elapsed_time(),
95 "stack_trace": self.run_exception.stack_trace
96 if hasattr(self.run_exception, "stack_trace")
97 else None,
98 "stream_exceeded": self.run_exception.exceeded_stream
99 if hasattr(self.run_exception, "exceeded_stream")
100 else None,
101 }
102 )
103 formatted_properties = {
104 key: self.format_value(value) for key, value in properties.items()
105 }
106 return formatted_properties

Member Data Documentation

◆ command

GaudiTesting.FixtureResult.FixtureResult.command = command

Definition at line 49 of file FixtureResult.py.

◆ completed_process

GaudiTesting.FixtureResult.FixtureResult.completed_process = completed_process

Definition at line 45 of file FixtureResult.py.

◆ cwd

GaudiTesting.FixtureResult.FixtureResult.cwd = cwd

Definition at line 52 of file FixtureResult.py.

◆ end_time

GaudiTesting.FixtureResult.FixtureResult.end_time = end_time

Definition at line 47 of file FixtureResult.py.

◆ expanded_command

GaudiTesting.FixtureResult.FixtureResult.expanded_command = expanded_command

Definition at line 50 of file FixtureResult.py.

◆ run_exception

GaudiTesting.FixtureResult.FixtureResult.run_exception = run_exception

Definition at line 48 of file FixtureResult.py.

◆ runtime_environment

GaudiTesting.FixtureResult.FixtureResult.runtime_environment = env

Definition at line 51 of file FixtureResult.py.

◆ start_time

GaudiTesting.FixtureResult.FixtureResult.start_time = start_time

Definition at line 46 of file FixtureResult.py.


The documentation for this class was generated from the following file: