[ovs-dev,01/55] python: Set up initial tox test environment.
diff mbox

Message ID 1450730875-18083-2-git-send-email-russell@ovn.org
State Deferred
Headers show

Commit Message

Russell Bryant Dec. 21, 2015, 8:47 p.m. UTC
tox is a tool for running Python tests in virtual Python environments.
This initial setup only attempts to install the ovs Python library in
both a virtual Python 2.7 environment and a virtual Python 3.4
environment.  We also run the beginning of a test suite, which only
imports the code.  This quickly reproduces the problem that the library
fails to install for Python 3.  Future patches will start addressing
Python 3 compatibility.

Signed-off-by: Russell Bryant <russell@ovn.org>
---
 python/.gitignore            |  3 +++
 python/automake.mk           | 10 +++++++++-
 python/ovs/tests/__init__.py |  1 +
 python/ovs/tests/test_ovs.py | 46 ++++++++++++++++++++++++++++++++++++++++++++
 python/requirements.txt      |  1 +
 python/test-requirements.txt |  2 ++
 python/tox.ini               | 13 +++++++++++++
 7 files changed, 75 insertions(+), 1 deletion(-)
 create mode 100644 python/ovs/tests/__init__.py
 create mode 100644 python/ovs/tests/test_ovs.py
 create mode 100644 python/requirements.txt
 create mode 100644 python/test-requirements.txt
 create mode 100644 python/tox.ini

Patch
diff mbox

diff --git a/python/.gitignore b/python/.gitignore
index 60ace6f..ddf3457 100644
--- a/python/.gitignore
+++ b/python/.gitignore
@@ -1,2 +1,5 @@ 
 dist/
 *.egg-info
+.tox/
+.cache/
+htmlcov
diff --git a/python/automake.mk b/python/automake.mk
index 42b428a..a86bcaa 100644
--- a/python/automake.mk
+++ b/python/automake.mk
@@ -33,7 +33,9 @@  ovs_pyfiles = \
 	python/ovs/unixctl/server.py \
 	python/ovs/util.py \
 	python/ovs/version.py \
-	python/ovs/vlog.py
+	python/ovs/vlog.py \
+	python/ovs/tests/__init__.py \
+	python/ovs/tests/test_ovs.py
 
 # These python files are used at build time but not runtime,
 # so they are not installed.
@@ -46,6 +48,12 @@  EXTRA_DIST += \
 	python/README.rst \
 	python/setup.py
 
+# Test suite related files
+EXTRA_DIST += \
+	python/tox.ini \
+	python/requirements.txt \
+	python/test-requirements.txt
+
 PYFILES = $(ovs_pyfiles) python/ovs/dirs.py $(ovstest_pyfiles)
 EXTRA_DIST += $(PYFILES)
 PYCOV_CLEAN_FILES += $(PYFILES:.py=.py,cover)
diff --git a/python/ovs/tests/__init__.py b/python/ovs/tests/__init__.py
new file mode 100644
index 0000000..218d892
--- /dev/null
+++ b/python/ovs/tests/__init__.py
@@ -0,0 +1 @@ 
+# This file intentionally left blank.
diff --git a/python/ovs/tests/test_ovs.py b/python/ovs/tests/test_ovs.py
new file mode 100644
index 0000000..2525259
--- /dev/null
+++ b/python/ovs/tests/test_ovs.py
@@ -0,0 +1,46 @@ 
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import unittest
+
+# Import everything from the ovs lib to ensure all modules show up in the
+# coverage report.  It also ensures that if we don't have test coverage yet,
+# they can at least be successfully imported.
+import ovs.jsonrpc  # noqa
+import ovs.tests.test_ovs  # noqa
+import ovs.version  # noqa
+import ovs.timeval  # noqa
+import ovs.daemon  # noqa
+import ovs.reconnect  # noqa
+import ovs.vlog  # noqa
+import ovs.json  # noqa
+import ovs.stream  # noqa
+import ovs.fatal_signal  # noqa
+import ovs.ovsuuid  # noqa
+import ovs.dirs  # noqa
+import ovs.util  # noqa
+import ovs.socket_util  # noqa
+import ovs.process  # noqa
+import ovs.poller  # noqa
+import ovs.unixctl.client  # noqa
+import ovs.unixctl.server  # noqa
+import ovs.db.data  # noqa
+import ovs.db.idl  # noqa
+import ovs.db.parser  # noqa
+import ovs.db.types  # noqa
+import ovs.db.schema  # noqa
+import ovs.db.error  # noqa
+
+
+class TestOVS(unittest.TestCase):
+    def test_pass(self):
+        pass
diff --git a/python/requirements.txt b/python/requirements.txt
new file mode 100644
index 0000000..e7c0136
--- /dev/null
+++ b/python/requirements.txt
@@ -0,0 +1 @@ 
+# runtime dependencies
diff --git a/python/test-requirements.txt b/python/test-requirements.txt
new file mode 100644
index 0000000..eae9d4f
--- /dev/null
+++ b/python/test-requirements.txt
@@ -0,0 +1,2 @@ 
+# test dependencies
+nose
diff --git a/python/tox.ini b/python/tox.ini
new file mode 100644
index 0000000..06b2e2a
--- /dev/null
+++ b/python/tox.ini
@@ -0,0 +1,13 @@ 
+# 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,py34
+
+[testenv]
+usedevelop = True
+commands = {envbindir}/nosetests ovs/tests
+deps = -r{toxinidir}/requirements.txt
+       -r{toxinidir}/test-requirements.txt