From a1fd088684659b8f36225e63f067e371ad135e25 Mon Sep 17 00:00:00 2001 From: luto Date: Tue, 16 Jul 2024 16:31:07 +0200 Subject: [PATCH] fix and test env var passing between fixtures and tests --- src/shellinspector/runner.py | 2 +- tests/e2e/900_fixtures.ispec | 4 +++- tests/e2e/fixtures/create_user_pre.ispec | 3 ++- tests/test_parser.py | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/shellinspector/runner.py b/src/shellinspector/runner.py index a83b04d..dfab120 100644 --- a/src/shellinspector/runner.py +++ b/src/shellinspector/runner.py @@ -460,7 +460,7 @@ def run(self, specfile: Specfile, outer_used_sessions=None): self.run(specfile.fixture_specfile_post, used_sessions) finally: - if not outer_used_sessions: + if outer_used_sessions is None: for session in used_sessions: session.pop_state() diff --git a/tests/e2e/900_fixtures.ispec b/tests/e2e/900_fixtures.ispec index 104a793..063d170 100644 --- a/tests/e2e/900_fixtures.ispec +++ b/tests/e2e/900_fixtures.ispec @@ -4,5 +4,7 @@ settings: fixture_dirs: - fixtures --- -%~ id create_user +% echo $USRNAME +create_user +%~ id $USRNAME create_user diff --git a/tests/e2e/fixtures/create_user_pre.ispec b/tests/e2e/fixtures/create_user_pre.ispec index 47b91a9..f4ba286 100644 --- a/tests/e2e/fixtures/create_user_pre.ispec +++ b/tests/e2e/fixtures/create_user_pre.ispec @@ -1 +1,2 @@ -% adduser -D create_user +% export USRNAME=create_user +% adduser -D $USRNAME diff --git a/tests/test_parser.py b/tests/test_parser.py index 09d887e..b267f8d 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -582,6 +582,6 @@ def test_fixture(): assert specfile.fixture == "e2e/fixtures/create_user" assert not specfile.errors, specfile.errors assert specfile.fixture_specfile_pre - assert len(specfile.fixture_specfile_pre.commands) == 1 + assert len(specfile.fixture_specfile_pre.commands) == 2 assert specfile.fixture_specfile_post assert len(specfile.fixture_specfile_post.commands) == 1