Skip to content

Commit

Permalink
Merge pull request #74 from robertopreste/enh/change-structure
Browse files Browse the repository at this point in the history
Change cookiecutter structure
  • Loading branch information
robertopreste committed Feb 9, 2020
2 parents 9b9b024 + d617fed commit 512a6f3
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 53 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development",
Expand Down
17 changes: 8 additions & 9 deletions tests/test_bake_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def test_bake_without_travis_pypi_setup(cookies):
) as result:
result_travis_config = yaml.load(result.project.join(".travis.yml").open())
assert "deploy" not in result_travis_config
assert "python" == result_travis_config["language"]
assert len(result_travis_config["matrix"]["include"]) == 4
found_toplevel_files = [f.basename for f in result.project.listdir()]


Expand Down Expand Up @@ -199,14 +199,13 @@ def test_using_pytest(cookies):
run_inside_dir("python setup.py test", str(result.project)) == 0


# drop this since pytest is the default
# def test_not_using_pytest(cookies):
# with bake_in_temp_dir(cookies) as result:
# assert result.project.isdir()
# test_file_path = result.project.join('tests/test_python_template.py')
# lines = test_file_path.readlines()
# assert "import unittest" in ''.join(lines)
# assert "import pytest" not in ''.join(lines)
def test_not_using_pytest(cookies):
with bake_in_temp_dir(cookies, extra_context={"use_pytest": "n"}) as result:
assert result.project.isdir()
test_file_path = result.project.join('tests/test_python_template.py')
lines = test_file_path.readlines()
assert "import unittest" in ''.join(lines)
assert "import pytest" not in ''.join(lines)


# def test_project_with_hyphen_in_module_name(cookies):
Expand Down
5 changes: 5 additions & 0 deletions {{cookiecutter.project_slug}}/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ venv.bak/

# mypy
.mypy_cache/

### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
Expand Down Expand Up @@ -218,6 +219,7 @@ Icon
Network Trash Folder
Temporary Items
.apdisk

### VirtualEnv template
# Virtualenv
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
Expand All @@ -232,3 +234,6 @@ pyvenv.cfg
.venv
pip-selfcheck.json

### VSCode

.vscode
2 changes: 2 additions & 0 deletions {{cookiecutter.project_slug}}/.pyup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
branch: master
update: insecure
78 changes: 52 additions & 26 deletions {{cookiecutter.project_slug}}/.travis.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,54 @@
# Config file for automatic testing at travis-ci.com

language: python
python:
- 3.6

# Command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
install: pip install -U tox-travis

# Command to run tests, e.g. python setup.py test
script: tox

{% if cookiecutter.use_pypi_deployment_with_travis == 'y' -%}
# Assuming you have installed the travis-ci CLI tool, after you
# create the Github repo and add it to Travis, run the
# following command to finish PyPI deployment setup:
# $ travis encrypt --add deploy.password
deploy:
provider: pypi
distributions: sdist bdist_wheel
user: {{ cookiecutter.pypi_username }}
password:
secure: PLEASE_REPLACE_ME
on:
tags: true
repo: {{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}
python: 3.6
{%- endif %}
matrix:
include:
- name: "Python 3.6.5 on macOS 10.13.6 (xcode 9.4)"
os: osx
osx_image: xcode9.4
language: shell
before_install:
- python3 --version
- pip3 install -U pip
- pip3 install -r requirements.txt
install: pip3 install -e .
script:
- pytest --cov=./
- flake8 {{ cookiecutter.project_slug }}
- name: "Python 3.7.5 on macOS 10.14.4 (xcode 10.2)"
os: osx
osx_image: xcode10.2
language: shell
before_install:
- python3 --version
- pip3 install -U pip
- pip3 install -r requirements.txt
install: pip3 install -e .
script:
- pytest --cov=./
- flake8 {{ cookiecutter.project_slug }}
- name: "Python 3.6.7 on Ubuntu 16.04"
os: linux
language: python
python: 3.6
before_install:
- python3 --version
- pip3 install -U pip
- pip3 install -r requirements.txt
install: pip3 install -e .
script:
- pytest --cov=./
- flake8 {{ cookiecutter.project_slug }}
- name: "Python 3.7.1 on Ubuntu 16.04"
os: linux
language: python
python: 3.7
before_install:
- python3 --version
- pip3 install -U pip
- pip3 install -r requirements.txt
install: pip3 install -e .
script:
- pytest --cov=./
- flake8 {{ cookiecutter.project_slug }}
after_success:
- codecov
25 changes: 13 additions & 12 deletions {{cookiecutter.project_slug}}/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
{% if cookiecutter.command_line_interface|lower == 'click' -%}
click==7.0{% endif %}

pip==19.2.3
bump2version==0.5.11
wheel==0.33.6
pip==20.0.2
bump2version==1.0.0
wheel==0.34.2
watchdog==0.9.0
flake8==3.7.8
tox==3.14.0
coverage==4.5.4
Sphinx==2.2.0
sphinx-click==2.3.0
flake8==3.7.9
tox==3.14.3
coverage==5.0.3
codecov==2.0.15
Sphinx==2.4.0
sphinx-click==2.3.1
sphinxcontrib-napoleon==0.7
twine==2.0.0
twine==3.1.1
{% if cookiecutter.use_pytest == 'y' -%}
pytest==5.2.0
pytest-runner==5.1
pytest-cov==2.7.1{% endif %}
pytest==5.3.5
pytest-runner==5.2
pytest-cov==2.8.1{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,16 @@ def test_cli(self):
"""Test the CLI."""
runner = CliRunner()
result = runner.invoke(cli.main)
assert result.exit_code == 0
assert "{{ cookiecutter.project_slug }}.cli.main" in result.output
self.assertEqual(0, result.exit_code)
self.assertIn("{{ cookiecutter.project_slug }}.cli.main",
result.output)
def test_cli_help(self):
"""Test the CLI help."""
runner = CliRunner()
result = runner.invoke(cli.main, ["--help"])
assert result.exit_code == 0
assert "--help Show this message and exit." in result.output
self.assertEqual(0, result.exit_code)
self.assertIn("--help Show this message and exit.",
result.output)
{%- endif %}
{%- endif %}
3 changes: 2 additions & 1 deletion {{cookiecutter.project_slug}}/tox.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[tox]
envlist = python3.6, flake8
envlist = python3.6, python3.7, flake8

[travis]
python =
3.6: python3.6
3.7: python3.7

[testenv:flake8]
basepython = python
Expand Down

0 comments on commit 512a6f3

Please sign in to comment.