From 5edc2410ea066a7df4c4af42492597aa1a07a9e5 Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Mon, 9 Apr 2018 10:44:30 -0700 Subject: [PATCH] Add tox, pre-commit and dummy test. --- .gitignore | 1 + .pre-commit-config.yaml | 24 ++++++++++++++++++++++++ Makefile | 9 ++++++++- requirements-dev.txt | 6 ++++++ tests/first_test.py | 6 ++++++ tox.ini | 24 ++++++++++++++++++++++++ 6 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 .pre-commit-config.yaml create mode 100644 tests/first_test.py create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index edc6c13..f200fef 100644 --- a/.gitignore +++ b/.gitignore @@ -44,6 +44,7 @@ htmlcov/ nosetests.xml coverage.xml *,cover +.pytest_cache/ # Translations *.mo diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..31823e8 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,24 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v1.2.3 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: autopep8-wrapper + args: + - -i + - --ignore=E265,E309,E501 + - id: debug-statements + language_version: python3 + - id: flake8 + language_version: python3 + - id: check-yaml + - id: check-merge-conflict + - id: name-tests-test + exclude: tests/(common.py|util.py|(helpers|integration/factories)/(.+).py) + - repo: https://github.com/asottile/reorder_python_imports + sha: v1.0.1 + hooks: + - id: reorder-python-imports + args: + - --py3-plus diff --git a/Makefile b/Makefile index b09ede0..ac6b584 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,15 @@ env: virtualenv -p python3 env - ./env/bin/pip install -r requirements.txt + ./env/bin/pip install -r requirements-dev.txt .PHONY: run run: env ./env/bin/python -m minitor.main +.PHONY: test +test: env + tox + .PHONY: build build: env ./env/bin/python setup.py sdist @@ -22,3 +26,6 @@ upload-test: env .PHONY: clean clean: rm -fr ./build ./dist ./minitor.egg-info + +install-hooks: + tox -e pre-commit -- install -f --install-hooks diff --git a/requirements-dev.txt b/requirements-dev.txt index 1599274..86c7ef6 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,9 @@ -r requirements.txt +coverage +flake8 +mock +pre-commit +pytest +tox twine wheel diff --git a/tests/first_test.py b/tests/first_test.py new file mode 100644 index 0000000..08c066c --- /dev/null +++ b/tests/first_test.py @@ -0,0 +1,6 @@ +class TestMain(object): + def test_something(self): + pass + + def test_something_else(self): + assert False diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..c809435 --- /dev/null +++ b/tox.ini @@ -0,0 +1,24 @@ +[tox] +envlist = py3 + +[testenv] +deps = + -rrequirements-dev.txt +commands = + coverage erase + coverage run --source=minitor/,tests/ -m pytest --capture=no -vv {posargs:tests} + coverage report -m --fail-under 50 + pre-commit run --all-files + +[testenv:pre-commit] +commands = + pre-commit {posargs} + +[flake8] +exclude = .svn,CVS,.bzr,.hg,.git,__pycache__,.ropeproject,.tox,docs,virtualenv_run +filename = *.py,*.wsgi +max-line-length = 80 +ignore = F403 + +[pytest] +norecursedirs = .* _darcs CVS docs virtualenv_run