24
24
logging .basicConfig (level = logging .INFO , format = "%(levelname)-8s %(message)s" )
25
25
26
26
27
- def handle_perf (start_time : datetime , end_time : datetime ):
27
+ def handle_perf (start_time : datetime ):
28
+ end_time = datetime .now ()
28
29
elapsed_secs = (end_time - start_time ).total_seconds ()
29
30
with open ("results.json" ) as fid :
30
31
results = json .load (fid )
@@ -68,24 +69,33 @@ def handle_green_framework() -> None:
68
69
LOGGER .info (f"Running tests with { GREEN_FRAMEWORK } ..." )
69
70
70
71
72
+ def handle_c_ext () -> None :
73
+ if platform .python_implementation () != "CPython" :
74
+ return
75
+ sys .path .insert (0 , str (ROOT / "tools" ))
76
+ from fail_if_no_c import main as fail_if_no_c
77
+
78
+ fail_if_no_c ()
79
+
80
+
81
+ def handle_pymongocrypt () -> None :
82
+ import pymongocrypt
83
+
84
+ LOGGER .info (f"pymongocrypt version: { pymongocrypt .__version__ } )" )
85
+ LOGGER .info (f"libmongocrypt version: { pymongocrypt .libmongocrypt_version ()} )" )
86
+
87
+
71
88
def run () -> None :
72
- # Handle green frameworks first so they can patch modules.
89
+ # Handle green framework first so they can patch modules.
73
90
if GREEN_FRAMEWORK :
74
91
handle_green_framework ()
75
92
76
93
# Ensure C extensions if applicable.
77
- if not os .environ .get ("NO_EXT" ) and platform .python_implementation () == "CPython" :
78
- sys .path .insert (0 , str (ROOT / "tools" ))
79
- from fail_if_no_c import main as fail_if_no_c
80
-
81
- fail_if_no_c ()
94
+ if not os .environ .get ("NO_EXT" ):
95
+ handle_c_ext ()
82
96
83
97
if os .environ .get ("PYMONGOCRYPT_LIB" ):
84
- # Ensure pymongocrypt is working properly.
85
- import pymongocrypt
86
-
87
- LOGGER .info (f"pymongocrypt version: { pymongocrypt .__version__ } )" )
88
- LOGGER .info (f"libmongocrypt version: { pymongocrypt .libmongocrypt_version ()} )" )
98
+ handle_pymongocrypt ()
89
99
90
100
LOGGER .info (f"Test setup:\n { AUTH = } \n { SSL = } \n { UV_ARGS = } \n { TEST_ARGS = } " )
91
101
@@ -98,8 +108,7 @@ def run() -> None:
98
108
99
109
# Handle perf test post actions.
100
110
if TEST_PERF :
101
- end_time = datetime .now ()
102
- handle_perf (start_time , end_time )
111
+ handle_perf (start_time )
103
112
104
113
# Handle coverage post actions.
105
114
if os .environ .get ("COVERAGE" ):
0 commit comments