From 6574f59aa23f3a0fefec0ccf38511ae1bf64cf93 Mon Sep 17 00:00:00 2001 From: "David R. MacIver" Date: Thu, 31 Oct 2024 15:29:15 +0000 Subject: [PATCH] Fix environ setting on Windows --- hypothesis-python/tests/cover/test_settings.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hypothesis-python/tests/cover/test_settings.py b/hypothesis-python/tests/cover/test_settings.py index 085a0c8965..4d27ed8ac7 100644 --- a/hypothesis-python/tests/cover/test_settings.py +++ b/hypothesis-python/tests/cover/test_settings.py @@ -9,6 +9,7 @@ # obtain one at https://mozilla.org/MPL/2.0/. import datetime +import os import subprocess import sys from unittest import TestCase @@ -520,6 +521,9 @@ def test_deprecated_settings_not_in_settings_all_list(): def test_check_defaults_to_derandomize_when_running_on_ci(): + env = dict(os.environ) + env["CI"] = "true" + assert ( subprocess.check_output( [ @@ -527,7 +531,7 @@ def test_check_defaults_to_derandomize_when_running_on_ci(): "-c", "from hypothesis import settings\nprint(settings().derandomize)", ], - env={"CI": "true"}, + env=env, text=True, encoding="utf-8", ).strip() @@ -536,6 +540,9 @@ def test_check_defaults_to_derandomize_when_running_on_ci(): def test_check_defaults_to_randomize_when_not_running_on_ci(): + env = dict(os.environ) + env.pop("CI", None) + env.pop("TF_BUILD", None) assert ( subprocess.check_output( [ @@ -543,7 +550,7 @@ def test_check_defaults_to_randomize_when_not_running_on_ci(): "-c", "from hypothesis import settings\nprint(settings().derandomize)", ], - env={}, + env=env, text=True, encoding="utf-8", ).strip()