Skip to content

Commit 60a19ae

Browse files
committed
test: isolate vscode user agent test
1 parent 6f11279 commit 60a19ae

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

packages/bigframes/tests/unit/session/test_clients.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,18 @@ def test_user_agent_not_in_vscode(monkeypatch):
182182
@mock.patch.dict(os.environ, {"VSCODE_PID": "12345"}, clear=True)
183183
def test_user_agent_in_vscode(monkeypatch):
184184
monkeypatch_client_constructors(monkeypatch)
185-
provider = create_clients_provider()
186-
assert_clients_w_user_agent(provider, "vscode")
187-
assert_clients_wo_user_agent(provider, "googlecloudtools.cloudcode")
188185

189-
# We still need to include attribution to bigframes
190-
assert_clients_w_user_agent(provider, f"bigframes/{bigframes.version.__version__}")
186+
with tempfile.TemporaryDirectory() as tmpdir:
187+
user_home = pathlib.Path(tmpdir)
188+
with mock.patch("pathlib.Path.home", return_value=user_home):
189+
provider = create_clients_provider()
190+
assert_clients_w_user_agent(provider, "vscode")
191+
assert_clients_wo_user_agent(provider, "googlecloudtools.cloudcode")
192+
193+
# We still need to include attribution to bigframes
194+
assert_clients_w_user_agent(
195+
provider, f"bigframes/{bigframes.version.__version__}"
196+
)
191197

192198

193199
@mock.patch.dict(os.environ, {"VSCODE_PID": "12345"}, clear=True)

0 commit comments

Comments
 (0)