diff --git a/tmt/steps/__init__.py b/tmt/steps/__init__.py index 30ad12f9eb..f582b5e05e 100644 --- a/tmt/steps/__init__.py +++ b/tmt/steps/__init__.py @@ -1958,16 +1958,16 @@ def _login( # Attempt to push the workdir to the guest try: guest.push() - worktree = self.parent.plan.worktree - test_path = self.parent.plan.discover.tests( - )[-1].path if self.parent.plan.discover.tests() else None + if not cwd: + worktree = self.parent.plan.worktree + tests = self.parent.plan.discover.tests() + test_path = tests[-1].path if tests else None - if worktree and test_path: - test_path = worktree.parent / "discover" / test_path.unrooted() - else: - test_path = worktree + if worktree and test_path: + cwd = worktree.parent / "discover" / test_path.unrooted() + else: + cwd = worktree - cwd = cwd or test_path except tmt.utils.GeneralError: self.warn("Failed to push workdir to the guest.") cwd = None