summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2017-03-30 19:26:06 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2017-03-30 19:27:50 +0800
commit032fe270a600cb8917cd9c81730a18cd0fee6e61 (patch)
tree9886d798f06bd6aadf4c0f6fb168c471c0a06928
parentd17daf1af5056040e5399af814ebd850a70a4a75 (diff)
add tox framework for pep8 and unittest
Change-Id: If783d387c29dad7fa472578ead2bcd5a6d42ee70 Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
-rw-r--r--.coveragerc28
-rw-r--r--.gitignore1
-rw-r--r--requirements.txt0
-rw-r--r--setup.py9
-rw-r--r--test-requirements.txt5
-rw-r--r--tests/__init__.py0
-rw-r--r--tests/unit/__init__.py0
-rw-r--r--tests/unit/test_placeholder.py2
-rw-r--r--tox.ini42
9 files changed, 87 insertions, 0 deletions
diff --git a/.coveragerc b/.coveragerc
new file mode 100644
index 00000000..d58e2766
--- /dev/null
+++ b/.coveragerc
@@ -0,0 +1,28 @@
+# .coveragerc to control coverage.py
+
+[run]
+branch = True
+source =
+ deploy
+ tests
+
+[report]
+# Regexes for lines to exclude from consideration
+exclude_lines =
+ # Have to re-enable the standard pragma
+ pragma: no cover
+
+ # Don't complain about missing debug-only code:
+ def __repr__
+ if self\.debug
+
+ # Don't complain if tests don't hit defensive assertion code:
+ raise AssertionError
+ raise NotImplementedError
+
+ # Don't complain if non-runnable code isn't run:
+ if 0:
+ if __name__ == .__main__.:
+
+ignore_errors = True
+
diff --git a/.gitignore b/.gitignore
index 078f1c9b..b636538f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,6 +42,7 @@ pip-delete-this-directory.txt
.tox/
.coverage
.cache
+coverage.xml
# Log files:
*.log
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/requirements.txt
diff --git a/setup.py b/setup.py
new file mode 100644
index 00000000..d556de77
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,9 @@
+#!/usr/bin/env python
+
+from setuptools import setup
+
+setup(
+ name="daisy",
+ version="master",
+ url="https://www.opnfv.org",
+)
diff --git a/test-requirements.txt b/test-requirements.txt
new file mode 100644
index 00000000..0483907e
--- /dev/null
+++ b/test-requirements.txt
@@ -0,0 +1,5 @@
+pytest
+pytest-cov
+pytest-faker
+pytest-mock
+
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/__init__.py
diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/unit/__init__.py
diff --git a/tests/unit/test_placeholder.py b/tests/unit/test_placeholder.py
new file mode 100644
index 00000000..457e464c
--- /dev/null
+++ b/tests/unit/test_placeholder.py
@@ -0,0 +1,2 @@
+def test_holder():
+ assert True
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 00000000..28fbf8f5
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,42 @@
+# Tox (http://tox.testrun.org/) is a tool for running tests
+# in multiple virtualenvs. This configuration file will run the
+# test suite on all supported python versions. To use it, "pip install tox"
+# and then run "tox" from this directory.
+
+[tox]
+envlist = py27,pep8
+skipsdist = True
+
+[testenv]
+usedevelop = True
+install_command = pip install -U {opts} {packages}
+deps =
+ -rrequirements.txt
+ -rtest-requirements.txt
+commands=
+ py.test \
+ --basetemp={envtmpdir} \
+ --cov \
+ --cov-report term-missing \
+ --cov-report xml \
+ {posargs}
+setenv=
+ HOME = {envtmpdir}
+ PYTHONPATH = {toxinidir}
+
+[testenv:pep8]
+deps = flake8
+commands = flake8 {toxinidir}
+
+[flake8]
+# H803 skipped on purpose per list discussion.
+# E123, E125 skipped as they are invalid PEP-8.
+
+show-source = True
+ignore = E123,E125,H803,E501
+builtins = _
+exclude = build,dist,doc,legacy,.eggs,.git,.tox,.venv
+
+[pytest]
+testpaths = tests
+python_functions = test_*