2424logging .basicConfig (level = logging .INFO , format = "%(levelname)-8s %(message)s" )
2525
2626
27- def handle_perf (start_time : datetime , end_time : datetime ):
27+ def handle_perf (start_time : datetime ):
28+ end_time = datetime .now ()
2829 elapsed_secs = (end_time - start_time ).total_seconds ()
2930 with open ("results.json" ) as fid :
3031 results = json .load (fid )
@@ -68,24 +69,33 @@ def handle_green_framework() -> None:
6869 LOGGER .info (f"Running tests with { GREEN_FRAMEWORK } ..." )
6970
7071
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+
7188def run () -> None :
72- # Handle green frameworks first so they can patch modules.
89+ # Handle green framework first so they can patch modules.
7390 if GREEN_FRAMEWORK :
7491 handle_green_framework ()
7592
7693 # 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 ()
8296
8397 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 ()
8999
90100 LOGGER .info (f"Test setup:\n { AUTH = } \n { SSL = } \n { UV_ARGS = } \n { TEST_ARGS = } " )
91101
@@ -98,8 +108,7 @@ def run() -> None:
98108
99109 # Handle perf test post actions.
100110 if TEST_PERF :
101- end_time = datetime .now ()
102- handle_perf (start_time , end_time )
111+ handle_perf (start_time )
103112
104113 # Handle coverage post actions.
105114 if os .environ .get ("COVERAGE" ):
0 commit comments