Skip to content

Commit 90f26e9

Browse files
committed
cleanup
1 parent 09952f0 commit 90f26e9

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

.evergreen/scripts/run_tests.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
HERE = Path(__file__).absolute().parent
1717
ROOT = HERE.parent.parent
18-
DRIVERS_TOOLS = os.environ.get("DRIVERS_TOOLS", "").replace(os.sep, "/")
19-
PLATFORM = "windows" if os.name == "nt" else sys.platform.lower()
2018
AUTH = os.environ.get("AUTH", "noauth")
2119
SSL = os.environ.get("SSL", "nossl")
2220
UV_ARGS = os.environ.get("UV_ARGS", "")
@@ -27,6 +25,29 @@
2725
LOGGER = logging.getLogger(__name__)
2826
logging.basicConfig(level=logging.INFO, format="%(levelname)-8s %(message)s")
2927

28+
# Handle green frameworks first so they can patch modules.
29+
if GREEN_FRAMEWORK:
30+
if GREEN_FRAMEWORK == "eventlet":
31+
import eventlet
32+
33+
# https://github.com/eventlet/eventlet/issues/401
34+
eventlet.sleep()
35+
eventlet.monkey_patch()
36+
elif GREEN_FRAMEWORK == "gevent":
37+
from gevent import monkey
38+
39+
monkey.patch_all()
40+
41+
# Never run async tests with a framework.
42+
if len(TEST_ARGS) <= 1:
43+
TEST_ARGS.extend(["-m", "not default_async and default"])
44+
else:
45+
for i in range(len(TEST_ARGS) - 1):
46+
if "-m" in TEST_ARGS[i]:
47+
TEST_ARGS[i + 1] = f"not default_async and {TEST_ARGS[i + 1]}"
48+
49+
LOGGER.info(f"Running tests with {GREEN_FRAMEWORK}...")
50+
3051
# Ensure C extensions if applicable.
3152
if not os.environ.get("NO_EXT") and platform.python_implementation() == "CPython":
3253
sys.path.insert(0, str(ROOT / "tools"))
@@ -41,39 +62,18 @@
4162
LOGGER.info(f"pymongocrypt version: {pymongocrypt.__version__})")
4263
LOGGER.info(f"libmongocrypt version: {pymongocrypt.libmongocrypt_version()})")
4364

44-
LOGGER.info(f"Running {AUTH} tests over {SSL} with python {sys.executable}")
45-
4665
# Show the installed packages. Pip can only be run as a cli.
4766
env = os.environ.copy()
4867
env["PIP_QUIET"] = "0"
68+
LOGGER.info("Installed packages:")
4969
subprocess.run(shlex.split(f"uv run {UV_ARGS} --with pip pip list"), env=env, check=True) # noqa: S603
5070

71+
LOGGER.info(f"Test setup:\n{AUTH=}\n{SSL=}\n{UV_ARGS=}\n{TEST_ARGS=}")
72+
5173
# Record the start time for a perf test.
5274
if TEST_PERF:
5375
start_time = datetime.now()
5476

55-
# Handle green frameworks.
56-
if GREEN_FRAMEWORK:
57-
if GREEN_FRAMEWORK == "eventlet":
58-
import eventlet
59-
60-
# https://github.com/eventlet/eventlet/issues/401
61-
eventlet.sleep()
62-
eventlet.monkey_patch()
63-
elif GREEN_FRAMEWORK == "gevent":
64-
from gevent import monkey
65-
66-
monkey.patch_all()
67-
68-
# Never run async tests with a framework.
69-
if len(TEST_ARGS) <= 1:
70-
TEST_ARGS.extend(["-m", "not default_async and default"])
71-
else:
72-
for i in range(len(TEST_ARGS) - 1):
73-
if "-m" in TEST_ARGS[i]:
74-
TEST_ARGS[i + 1] = f"not default_async and {TEST_ARGS[i + 1]}"
75-
76-
7777
# Run the tests.
7878
pytest.main(TEST_ARGS)
7979

@@ -82,7 +82,7 @@
8282
end_time = datetime.now()
8383
elapsed_secs = (end_time - start_time).total_seconds()
8484
with open("results.json") as fid:
85-
print(json.dump(fid, indent=2)) # noqa: T201
85+
LOGGER.info("results.json:\n%s", json.dump(fid, indent=2))
8686

8787
results = dict(
8888
status="pass",
@@ -93,7 +93,7 @@
9393
elapsed=elapsed_secs,
9494
)
9595
report = dict(failures=0, results=results)
96-
print(json.dumps(report, indent=2)) # noqa: T201
96+
LOGGER.info("report.json\n%s", json.dumps(report, indent=2))
9797

9898
with open("report.json", "w", newline="\n") as fid:
9999
json.dump(report, fid)

0 commit comments

Comments
 (0)