Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ docs/*.png

# Testing and coverage results
.coverage
pyunit.xml

# Build and release directories
build
Expand Down
5 changes: 2 additions & 3 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
# I0011: Locally disabling %s
# W0142: Used * or ** magic
# W0511: TODO in comments
disable=I0011,W0142,W0511
# R0904: Too many public methods
disable=I0011,W0142,W0511,R0904

[REPORTS]

output-format=colorized

reports=no

msg-template={msg_id}:{line:3d},{column}:{msg}
Expand Down
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ language: python
python:
- 3.3
- 3.4
env:
- TEST_RUNNER=nose
- TEST_RUNNER=pytest
install:
- pip install coveralls scrutinizer-ocular
script: make ci
Expand Down
36 changes: 31 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
PYTHON_MAJOR := 3
PYTHON_MINOR := 4

# Test runner settings
ifndef TEST_RUNNER
# options are: nose, pytest
TEST_RUNNER := nose
endif

# Project settings (automatically detected from files/directories)
PROJECT := $(patsubst ./%.sublime-project,%, $(shell find . -type f -name '*.sublime-p*'))
PACKAGE := $(patsubst ./%/__init__.py,%, $(shell find . -maxdepth 2 -name '__init__.py'))
Expand Down Expand Up @@ -46,6 +52,8 @@ PEP257 := $(BIN)/pep257
PYLINT := $(BIN)/pylint
PYREVERSE := $(BIN)/pyreverse
NOSE := $(BIN)/nosetests
PYTEST := $(BIN)/py.test
COVERAGE := $(BIN)/coverage

# Flags for PHONY targets
DEPENDS_CI := $(ENV)/.depends-ci
Expand All @@ -67,7 +75,7 @@ ci: pep8 pep257 test tests

.PHONY: env
env: .virtualenv $(EGG_INFO)
$(EGG_INFO): Makefile setup.py
$(EGG_INFO): Makefile setup.py requirements.txt
$(PYTHON) setup.py develop
touch $(EGG_INFO) # flag to indicate package is installed

Expand All @@ -82,7 +90,7 @@ depends: .depends-ci .depends-dev
.PHONY: .depends-ci
.depends-ci: env Makefile $(DEPENDS_CI)
$(DEPENDS_CI): Makefile
$(PIP) install --upgrade pep8 pep257 nose coverage
$(PIP) install --upgrade pep8 pep257 $(TEST_RUNNER) coverage
touch $(DEPENDS_CI) # flag to indicate dependencies are installed

.PHONY: .depends-dev
Expand Down Expand Up @@ -144,13 +152,31 @@ pylint: .depends-dev
# Testing ####################################################################

.PHONY: test
test: .depends-ci
$(NOSE) --config=.noserc
test: test-$(TEST_RUNNER)

.PHONY: tests
tests: .depends-ci
tests: tests-$(TEST_RUNNER)

# Nosetest commands
.PHONY: test-nose
test-nose: .depends-ci
$(NOSE) --config=.noserc

.PHONY: tests-nose
tests-nose: .depends-ci
TEST_INTEGRATION=1 $(NOSE) --config=.noserc --cover-package=$(PACKAGE) -xv

# Pytest commands
.PHONY: test-py.test
test-pytest: .depends-ci
$(COVERAGE) run --source $(PACKAGE) -m py.test $(PACKAGE) --junitxml=pyunit.xml
$(COVERAGE) report -m

.PHONY: tests-py.test
tests-pytest: .depends-ci
TEST_INTEGRATION=1 $(COVERAGE) run --source $(PACKAGE) -m py.test $(PACKAGE) --junitxml=pyunit.xml
$(COVERAGE) report -m

# Cleanup ####################################################################

.PHONY: clean
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ To adopt for a new project:

* replace `foobar` and `template-python` with your package name
* replace `Foobar` with your project name (might be the same as the package)
* set `TEST_RUNNER` in the `Makefile` to your preferred test runner (`nose` or `pytest`)
* remove the `TEST_RUNNER` environment lines in `.travis.yml`
* update the links to point to your code repository and badges
* change the license

Expand Down
18 changes: 18 additions & 0 deletions foobar/test/test_foobar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env python

"""Sample test module."""

import unittest


class TestFooBar(unittest.TestCase):

"""Sample test class."""

def test_dependency_import(self):
"""Sample test method."""
try:
import testpackage # pylint: disable=W0612
assert True
except ImportError:
self.fail()
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
testpackage==2.26
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@
'Programming Language :: Python :: 3.3',
],

install_requires=[],
install_requires=open('requirements.txt').readlines(),
)