Skip to content

Commit 8f04756

Browse files
committed
fixup! feat(Session.new_window): set up environment
1 parent 214c692 commit 8f04756

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

tests/test_session.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,20 +264,31 @@ def test_cmd_inserts_sesion_id(session: Session) -> None:
264264
has_lt_version("3.0"),
265265
reason="needs -e flag for new-window which was introduced in 3.0",
266266
)
267-
def test_new_window_with_environment(session: Session) -> None:
267+
@pytest.mark.parametrize(
268+
"environment",
269+
[
270+
{"ENV_VAR": "window"},
271+
{"ENV_VAR_1": "window_1", "ENV_VAR_2": "window_2"},
272+
],
273+
)
274+
def test_new_window_with_environment(
275+
session: Session,
276+
environment: t.Dict[str, str],
277+
) -> None:
268278
env = shutil.which("env")
269279
assert env is not None, "Cannot find usable `env` in PATH."
270280

271281
window = session.new_window(
272282
attach=True,
273283
window_name="window_with_environment",
274284
window_shell=f"{env} PS1='$ ' sh",
275-
environment={"ENV_VAR": "window"},
285+
environment=environment,
276286
)
277287
pane = window.attached_pane
278288
assert pane is not None
279-
pane.send_keys("echo $ENV_VAR")
280-
assert pane.capture_pane() == ["$ echo $ENV_VAR", "window", "$"]
289+
for k, v in environment.items():
290+
pane.send_keys(f"echo ${k}")
291+
assert pane.capture_pane()[-2] == v
281292

282293

283294
@pytest.mark.skipif(

0 commit comments

Comments
 (0)