Skip to content

Commit

Permalink
Update Makefile to have 'python -m' as prefix for all pip commands to…
Browse files Browse the repository at this point in the history
… keep it consistent; update test_bake_project.py with make commands for executing tests for linting and pytest
  • Loading branch information
zhiwei2017 committed Sep 6, 2021
1 parent 47af987 commit 7b7efa1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ install_requirements:

# Install requirements for testing and run tests
test:
pip install -r requirements/dev.txt
pytest
python -m pip install -r requirements/dev.txt
pytest --instafail
10 changes: 3 additions & 7 deletions tests/test_bake_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,13 @@ def test_error_if_incompatible(cookies, context, invalid_context):
assert isinstance(result.exception, FailedHookException)


def linting_check(cookies, linting_type, context_override, call_params=None):
def linting_check(cookies, linting_type, context_override):
"""Generated project should pass flake8."""
result = cookies.bake(extra_context=context_override)
if call_params is None:
call_params = []
call_params.append(result.context['project_slug'])
try:
current_dir = str(sh.pwd("-P")).replace("\n", "")
sh.cd(str(result.project))
sh.pip("install", "-r", os.path.join("requirements", "base.txt"))
getattr(sh, linting_type)(*call_params)
sh.make(linting_type)
sh.cd(current_dir)
sh.rm("-r", str(result.project))
except sh.ErrorReturnCode as e:
Expand All @@ -129,7 +125,7 @@ def test_mypy_passes(cookies, context_override):
@pytest.mark.parametrize("context_override", pytest.SUPPORTED_COMBINATIONS, ids=_fixture_id)
def test_bandit_passes(cookies, context_override):
"""Generated project should pass bandit."""
linting_check(cookies, "bandit", context_override, call_params=['-r'])
linting_check(cookies, "bandit", context_override)


@pytest.mark.parametrize("context_override", pytest.SUPPORTED_COMBINATIONS, ids=_fixture_id)
Expand Down
10 changes: 5 additions & 5 deletions {{cookiecutter.project_slug}}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,24 @@ install_requirements:

# Install and run bandit security analysis
bandit:
pip install bandit
python -m pip install bandit
bandit -r $(SOURCE_DIR)

# Install and run mypy type checking
mypy:
pip install -r requirements/dev.txt
python -m pip install -r requirements/dev.txt
mypy $(SOURCE_DIR)

# Install and run flake8 linting
flake8:
pip install flake8
python -m pip install flake8
flake8 $(SOURCE_DIR)

# Install requirements for testing and run tests
test:
pip install -r requirements/dev.txt
python -m pip install -r requirements/dev.txt
python -m pip install -e .
pytest
pytest --instafail

# build wheel package
build_whl:
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .version import __version__
from .version import __version__

0 comments on commit 7b7efa1

Please sign in to comment.