Skip to content
This repository has been archived by the owner on Aug 11, 2023. It is now read-only.

Commit

Permalink
Updated test
Browse files Browse the repository at this point in the history
  • Loading branch information
constrict0r committed Nov 12, 2018
1 parent c8c1686 commit 30d9ba7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
1 change: 0 additions & 1 deletion amanita/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def main(path, direnv, venv, venv_path):
"""Creates a customizable python project
Package main entry point.
"""

project.Project.create(path, direnv, venv, venv_path)
24 changes: 15 additions & 9 deletions amanita/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,21 @@ class Project:
def create(path, direnv=False, venv=False, venv_path=None):
"""Create customizable python projects.
Each project includes a package directory layout and optionally:
Each project includes a package directory layout and optionally:
- A virtual enviroment inside or outside the project folder.
- `Direnv <https://direnv.net>`_ console switcher configuration (linux).
- A virtual enviroment inside or outside the project.
Args:
path (str): Path where to create the project.
direnv (bool): Configure direnv.
venv (bool): Create a virtual enviroment inside the project folder.
venv_path (str): Create a virtual enviroment on the given path.
"""
- `Direnv <https://direnv.net>`_ configuration.
Args:
path (str): Path where to create the project.
direnv (bool): Configure direnv.
venv (bool): Create a virtual enviroment inside the project folder.
venv_path (str): Create a virtual enviroment on the given path.
Returns:
bool: True for success, False otherwise.
"""
# Create package folder structure.
try:
assert subprocess.call('poetry new -- ' +
Expand All @@ -45,6 +49,8 @@ def create(path, direnv=False, venv=False, venv_path=None):
if venv_path is not None:
amanita.project.Project.venv_setup(venv_path)

return True

# Create virtual enviroment.
@staticmethod
def venv_setup(path):
Expand Down
14 changes: 14 additions & 0 deletions tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,17 @@ def test_create_project_venv_out_forbidden():
subprocess.check_call('amanita muscaria -e /root',
env=os.environ.copy(),
shell=True)


# Create project with virtual enviroment inside and
# outside the project directory.
def test_create_project_venv_in_out():

shutil.rmtree(os.path.join('muscaria'))
subprocess.check_call('amanita muscaria -v -e venv',
env=os.environ.copy(),
shell=True)
assert os.path.isdir('muscaria/.venv')
assert os.path.isdir('venv')
shutil.rmtree(os.path.join('muscaria'))
shutil.rmtree(os.path.join('venv'))

0 comments on commit 30d9ba7

Please sign in to comment.