From e0ef2d60623608d163a82470b8d1dedb1fd8072e Mon Sep 17 00:00:00 2001 From: Pavol Juhas Date: Mon, 30 Oct 2023 14:44:29 -0700 Subject: [PATCH] Run unit tests without affecting user browser session Exercise the `open_in_browser` argument from the test_generate_html_file_with_browser test, but do not affect the actual browser session. --- cirq-web/cirq_web/widget_test.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cirq-web/cirq_web/widget_test.py b/cirq-web/cirq_web/widget_test.py index 679f2294e70..a5c89e65469 100644 --- a/cirq-web/cirq_web/widget_test.py +++ b/cirq-web/cirq_web/widget_test.py @@ -12,7 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os from pathlib import Path +from unittest import mock + import cirq_web @@ -50,6 +53,7 @@ def test_repr_html(tmpdir): assert remove_whitespace(expected) == remove_whitespace(actual) +@mock.patch.dict(os.environ, {"BROWSER": "true"}) def test_generate_html_file_with_browser(tmpdir): # # Reset the path so the files are accessible cirq_web.widget._DIST_PATH = Path(tmpdir) / "dir"