Skip to content

Commit

Permalink
Put repetitive code in a loop, reorder tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
fperez committed Feb 10, 2017
1 parent 6102302 commit a3a60cf
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions edev.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,25 @@ def main(args: T.Optional[list]=None) -> int:
d.mkdir(parents=True, exist_ok=True)

# Symlink env. config scripts inside conda activ/deact directories
eon = acti_dir/EDEV_ON
eoff = deac_dir/EDEV_OFF

if not eon.is_symlink():
eon.symlink_to(BIN/EDEV_ON)
if not eoff.is_symlink():
eoff.symlink_to(BIN/EDEV_OFF)
for script, cdir in [(EDEV_ON, acti_dir), (EDEV_OFF, deac_dir)]:
src = cdir/script
if not src.is_symlink():
src.symlink_to(BIN/script)

print(f"Environment dev overlay `{ename}` ready at `{edev_dir}`")

return 0


# Unit tests
def test_noenv():
assert main(['__BADENV_NAME_zyxw__']) == 1


def test_no_args():
assert main([]) == 1


def test_noenv():
assert main(['__BADENV_NAME_zyxw__']) == 1


def test_normal():
import functools
import subprocess
Expand Down

0 comments on commit a3a60cf

Please sign in to comment.