Skip to content

Commit

Permalink
Revert "Remove unnecessary path resolution"
Browse files Browse the repository at this point in the history
This reverts commit 05182ef.

This introduced a bug where entering a sub-directory would deactivate
the environment.
  • Loading branch information
hsaunders1904 committed Apr 20, 2023
1 parent d8c0c66 commit af3ea42
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pyautoenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def parse_args(argv: List[str], stdout: TextIO) -> str:
# is not too complex. We won't get a full 'bells and whistles' CLI
# experience, but that's fine for our use-case.
if len(argv) == 0:
return "."
return os.getcwd()
if any(h in argv for h in ["-h", "--help"]):
stdout.write(CLI_HELP)
sys.exit(0)
Expand All @@ -83,7 +83,7 @@ def parse_args(argv: List[str], stdout: TextIO) -> str:
raise ValueError( # noqa: TRY003
f"exactly one argument expected, found {len(argv)}",
)
return argv[0]
return os.path.abspath(argv[0])


def discover_env(directory: str) -> Union[str, None]:
Expand Down
4 changes: 2 additions & 2 deletions test_pyautoenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def setup_method(self):
def test_directory_is_cwd_by_default(self):
directory = pyautoenv.parse_args([], self.stdout)

assert os.path.samefile(directory, Path.cwd())
assert directory == str(Path.cwd())

def test_directory_is_set(self):
directory = pyautoenv.parse_args(["/some/dir"], self.stdout)
Expand Down Expand Up @@ -167,7 +167,7 @@ def test_deactivate_and_activate_switching_to_new_venv(
activator,
):
stdout = StringIO()
new_venv_activate = Path("pyproj2/.venv") / activator
new_venv_activate = Path("/pyproj2/.venv") / activator
fs.create_file(new_venv_activate)
activate_venv(self.VENV_DIR)

Expand Down

0 comments on commit af3ea42

Please sign in to comment.