Skip to content

Commit 38ad677

Browse files
authored
Merge branch 'master' into PYTHON-5309
2 parents 3ea4de7 + d51c70b commit 38ad677

File tree

9 files changed

+21
-20
lines changed

9 files changed

+21
-20
lines changed

.evergreen/generated_configs/variants.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ buildvariants:
620620
- macos-14
621621
batchtime: 10080
622622
expansions:
623-
TEST_NAME: pyopenssl
623+
SUB_TEST_NAME: pyopenssl
624624
PYTHON_BINARY: /Library/Frameworks/Python.Framework/Versions/3.9/bin/python3
625625
- name: pyopenssl-rhel8-python3.10
626626
tasks:
@@ -631,7 +631,7 @@ buildvariants:
631631
- rhel87-small
632632
batchtime: 10080
633633
expansions:
634-
TEST_NAME: pyopenssl
634+
SUB_TEST_NAME: pyopenssl
635635
PYTHON_BINARY: /opt/python/3.10/bin/python3
636636
- name: pyopenssl-rhel8-python3.11
637637
tasks:
@@ -642,7 +642,7 @@ buildvariants:
642642
- rhel87-small
643643
batchtime: 10080
644644
expansions:
645-
TEST_NAME: pyopenssl
645+
SUB_TEST_NAME: pyopenssl
646646
PYTHON_BINARY: /opt/python/3.11/bin/python3
647647
- name: pyopenssl-rhel8-python3.12
648648
tasks:
@@ -653,7 +653,7 @@ buildvariants:
653653
- rhel87-small
654654
batchtime: 10080
655655
expansions:
656-
TEST_NAME: pyopenssl
656+
SUB_TEST_NAME: pyopenssl
657657
PYTHON_BINARY: /opt/python/3.12/bin/python3
658658
- name: pyopenssl-win64-python3.13
659659
tasks:
@@ -664,7 +664,7 @@ buildvariants:
664664
- windows-64-vsMulti-small
665665
batchtime: 10080
666666
expansions:
667-
TEST_NAME: pyopenssl
667+
SUB_TEST_NAME: pyopenssl
668668
PYTHON_BINARY: C:/python/Python313/python.exe
669669
- name: pyopenssl-rhel8-pypy3.10
670670
tasks:
@@ -675,7 +675,7 @@ buildvariants:
675675
- rhel87-small
676676
batchtime: 10080
677677
expansions:
678-
TEST_NAME: pyopenssl
678+
SUB_TEST_NAME: pyopenssl
679679
PYTHON_BINARY: /opt/python/pypy3.10/bin/python3
680680

681681
# Search index tests

.evergreen/scripts/generate_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def create_enterprise_auth_variants():
250250
def create_pyopenssl_variants():
251251
base_name = "PyOpenSSL"
252252
batchtime = BATCHTIME_WEEK
253-
expansions = dict(TEST_NAME="pyopenssl")
253+
expansions = dict(SUB_TEST_NAME="pyopenssl")
254254
variants = []
255255

256256
for python in ALL_PYTHONS:

.evergreen/scripts/run_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def run() -> None:
181181
return
182182

183183
if os.environ.get("DEBUG_LOG"):
184-
TEST_ARGS.extend(f"-o log_cli_level={logging.DEBUG} -o log_cli=1".split())
184+
TEST_ARGS.extend(f"-o log_cli_level={logging.DEBUG}".split())
185185

186186
# Run local tests.
187187
ret = pytest.main(TEST_ARGS + sys.argv[1:])

.evergreen/scripts/setup-tests.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@ if [ -f $SCRIPT_DIR/env.sh ]; then
2020
source $SCRIPT_DIR/env.sh
2121
fi
2222

23+
echo "Setting up tests with args \"$*\"..."
2324
uv run $SCRIPT_DIR/setup_tests.py "$@"
25+
echo "Setting up tests with args \"$*\"... done."

.evergreen/scripts/setup_tests.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@ def handle_test_env() -> None:
394394
load_config_from_file(csfle_dir / "secrets-export.sh")
395395
run_command(f"bash {csfle_dir.as_posix()}/start-servers.sh")
396396

397-
if sub_test_name == "pyopenssl":
398-
UV_ARGS.append("--extra ocsp")
397+
if sub_test_name == "pyopenssl":
398+
UV_ARGS.append("--extra ocsp")
399399

400400
if is_set("TEST_CRYPT_SHARED") or opts.crypt_shared:
401401
config = read_env(f"{DRIVERS_TOOLS}/mo-expansion.sh")
@@ -468,9 +468,7 @@ def handle_test_env() -> None:
468468
UV_ARGS.append(f"--group {framework}")
469469

470470
else:
471-
# Use --capture=tee-sys so pytest prints test output inline:
472-
# https://docs.pytest.org/en/stable/how-to/capture-stdout-stderr.html
473-
TEST_ARGS = f"-v --capture=tee-sys --durations=5 {TEST_ARGS}"
471+
TEST_ARGS = f"-v --durations=5 {TEST_ARGS}"
474472
TEST_SUITE = TEST_SUITE_MAP.get(test_name)
475473
if TEST_SUITE:
476474
TEST_ARGS = f"-m {TEST_SUITE} {TEST_ARGS}"

.evergreen/scripts/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ class Distro:
4343
"kms": "kms",
4444
"load_balancer": "load_balancer",
4545
"mockupdb": "mockupdb",
46-
"pyopenssl": "",
4746
"ocsp": "ocsp",
4847
"perf": "perf",
4948
"serverless": "",

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,11 @@ If you are running one of the `no-responder` tests, omit the `run-server` step.
352352

353353
## Enable Debug Logs
354354

355-
- Use `-o log_cli_level="DEBUG" -o log_cli=1` with `just test` or `pytest`.
356-
- Add `log_cli_level = "DEBUG` and `log_cli = 1` to the `tool.pytest.ini_options` section in `pyproject.toml` for Evergreen patches or to enable debug logs by default on your machine.
357-
- You can also set `DEBUG_LOG=1` and run either `just setup-tests` or `just-test`.
355+
- Use `-o log_cli_level="DEBUG" -o log_cli=1` with `just test` or `pytest` to output all debug logs to the terminal. **Warning**: This will output a huge amount of logs.
356+
- Add `log_cli=1` and `log_cli_level="DEBUG"` to the `tool.pytest.ini_options` section in `pyproject.toml` to enable debug logs in this manner by default on your machine.
357+
- Set `DEBUG_LOG=1` and run `just setup-tests`, `just-test`, or `pytest` to enable debug logs only for failed tests.
358358
- Finally, you can use `just setup-tests --debug-log`.
359-
- For evergreen patch builds, you can use `evergreen patch --param DEBUG_LOG=1` to enable debug logs for the patch.
359+
- For evergreen patch builds, you can use `evergreen patch --param DEBUG_LOG=1` to enable debug logs for failed tests in the patch.
360360

361361
## Adding a new test suite
362362

test/asynchronous/test_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import time
3535
import uuid
3636
from typing import Any, Iterable, Type, no_type_check
37-
from unittest import mock
37+
from unittest import mock, skipIf
3838
from unittest.mock import patch
3939

4040
import pytest
@@ -629,6 +629,7 @@ def test_detected_environment_logging(self, mock_get_hosts):
629629
logs = [record.getMessage() for record in cm.records if record.name == "pymongo.client"]
630630
self.assertEqual(len(logs), 7)
631631

632+
@skipIf(os.environ.get("DEBUG_LOG"), "Enabling debug logs breaks this test")
632633
@patch("pymongo.asynchronous.srv_resolver._SrvResolver.get_hosts")
633634
async def test_detected_environment_warning(self, mock_get_hosts):
634635
with self._caplog.at_level(logging.WARN):

test/test_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import time
3535
import uuid
3636
from typing import Any, Iterable, Type, no_type_check
37-
from unittest import mock
37+
from unittest import mock, skipIf
3838
from unittest.mock import patch
3939

4040
import pytest
@@ -622,6 +622,7 @@ def test_detected_environment_logging(self, mock_get_hosts):
622622
logs = [record.getMessage() for record in cm.records if record.name == "pymongo.client"]
623623
self.assertEqual(len(logs), 7)
624624

625+
@skipIf(os.environ.get("DEBUG_LOG"), "Enabling debug logs breaks this test")
625626
@patch("pymongo.synchronous.srv_resolver._SrvResolver.get_hosts")
626627
def test_detected_environment_warning(self, mock_get_hosts):
627628
with self._caplog.at_level(logging.WARN):

0 commit comments

Comments
 (0)