From 27abaea1eae7b628b4fbf91e4f36c400a90c2911 Mon Sep 17 00:00:00 2001 From: James Page Date: Tue, 23 Jun 2015 09:51:33 +0100 Subject: [PATCH] Add DEP-8 execution of tests, fixup py3 compatibility --- debian/control | 3 ++ debian/patches/py3-compat.patch | 51 +++++++++++++++++++++++++++++++++ debian/patches/series | 1 + debian/rules | 17 ----------- debian/tests/control | 3 ++ debian/tests/unittests | 23 +++++++++++++++ 6 files changed, 81 insertions(+), 17 deletions(-) create mode 100644 debian/patches/py3-compat.patch create mode 100644 debian/patches/series create mode 100644 debian/tests/control create mode 100644 debian/tests/unittests diff --git a/debian/control b/debian/control index 4bfa355..9b4e183 100644 --- a/debian/control +++ b/debian/control @@ -18,10 +18,12 @@ Build-Depends-Indep: python-babel (>= 1.3), python-hacking, python-oslosphinx (>= 2.2.0), python-oslotest (>= 1.2.0), + python-six (>= 1.9.0), python-testscenarios (>= 0.4), python-testtools (>= 0.9.36), python3-babel (>= 1.3), python3-oslotest (>= 1.2.0), + python3-six (>= 1.9.0), python3-testscenarios (>= 0.4), python3-testtools (>= 0.9.36), subunit (>= 0.0.18), @@ -30,6 +32,7 @@ Standards-Version: 3.9.6 Vcs-Browser: http://anonscm.debian.org/gitweb/?p=openstack/python-os-testr.git Vcs-Git: git://anonscm.debian.org/openstack/python-os-testr.git Homepage: http://github.com/openstack/os-testr +XS-Testsuite: autopkgtest Package: python-os-testr Architecture: all diff --git a/debian/patches/py3-compat.patch b/debian/patches/py3-compat.patch new file mode 100644 index 0000000..ec19ca6 --- /dev/null +++ b/debian/patches/py3-compat.patch @@ -0,0 +1,51 @@ +From 4292155e3e546064d10d56a5a0cd1dedc7eb25bd Mon Sep 17 00:00:00 2001 +From: James Page +Date: Tue, 23 Jun 2015 09:47:44 +0100 +Subject: [PATCH] Misc Python 3 compatibility fixes + +Python 3 renames StringIO -> io. Use six to deal +with this change. + +Introduces new test dependency on six for StringIO. + +Change-Id: Ia875b7fcbb976599053970ef79ed3f3474626bad +--- + os_testr/tests/test_return_codes.py | 6 +++--- + test-requirements.txt | 1 + + 2 files changed, 4 insertions(+), 3 deletions(-) + +--- a/os_testr/tests/test_return_codes.py ++++ b/os_testr/tests/test_return_codes.py +@@ -14,13 +14,13 @@ + + import os + import shutil +-import StringIO + import subprocess + import tempfile + + import testtools + + from os_testr.tests import base ++from six import StringIO + + DEVNULL = open(os.devnull, 'wb') + +@@ -47,8 +47,8 @@ class TestReturnCodes(base.TestCase): + shutil.copy('os_testr/tests/files/setup.cfg', self.setup_cfg_file) + shutil.copy('os_testr/tests/files/__init__.py', self.init_file) + +- self.stdout = StringIO.StringIO() +- self.stderr = StringIO.StringIO() ++ self.stdout = StringIO() ++ self.stderr = StringIO() + # Change directory, run wrapper and check result + self.addCleanup(os.chdir, os.path.abspath(os.curdir)) + os.chdir(self.directory) +--- a/test-requirements.txt ++++ b/test-requirements.txt +@@ -10,3 +10,4 @@ sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3 + oslosphinx>=2.2.0 # Apache-2.0 + oslotest>=1.2.0 # Apache-2.0 + testscenarios>=0.4 ++six>=1.9.0 diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..aff3d2a --- /dev/null +++ b/debian/patches/series @@ -0,0 +1 @@ +py3-compat.patch diff --git a/debian/rules b/debian/rules index 1bc7ce7..4addc89 100755 --- a/debian/rules +++ b/debian/rules @@ -26,23 +26,6 @@ override_dh_install: mv $(CURDIR)/debian/python-os-testr/usr/bin/subunit2html $(CURDIR)/debian/python-os-testr/usr/bin/python2-subunit2html mv $(CURDIR)/debian/python3-os-testr/usr/bin/subunit2html $(CURDIR)/debian/python3-os-testr/usr/bin/python3-subunit2html -override_dh_auto_test: -ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS))) -# @echo "===> Running tests" -# set -e ; set -x ; for i in $(PYTHONS) $(PYTHON3S); do \ -# PYMAJOR=`echo $$i | cut -d'.' -f1` ; \ -# echo "===> Testing with python$$i (python$$PYMAJOR)" ; \ -# rm -rf .testrepository ; \ -# testr-python$$PYMAJOR init ; \ -# TEMP_REZ=`mktemp -t` ; \ -# PYTHONPATH=$(CURDIR) PYTHON=python$$i testr-python$$PYMAJOR run --subunit | tee $$TEMP_REZ | subunit2pyunit ; \ -# cat $$TEMP_REZ | subunit-filter -s --no-passthrough | subunit-stats ; \ -# rm -f $$TEMP_REZ ; \ -# testr-python$$PYMAJOR slowest ; \ -# done - : -endif - override_dh_sphinxdoc: sphinx-build -b html doc/source debian/python-os-testr-doc/usr/share/doc/python-os-testr-doc/html dh_sphinxdoc -O--buildsystem=python_distutils diff --git a/debian/tests/control b/debian/tests/control new file mode 100644 index 0000000..163a912 --- /dev/null +++ b/debian/tests/control @@ -0,0 +1,3 @@ +Tests: unittests +Depends: @, @builddeps@ +Restrictions: allow-stderr needs-root diff --git a/debian/tests/unittests b/debian/tests/unittests new file mode 100644 index 0000000..52cbaa9 --- /dev/null +++ b/debian/tests/unittests @@ -0,0 +1,23 @@ +#!/bin/sh + +PYTHONS=$(pyversions -vr) +PYTHON3S=$(py3versions -vr) + +BINARIES="ostestr subunit-trace subunit2html" + +set -e +echo "===> Running tests" +for i in ${PYTHONS} ${PYTHON3S}; do + PYMAJOR=`echo $i | cut -d'.' -f1` + echo "===> Testing with python$i (python$PYMAJOR)" + for bin in $BINARIES; do + update-alternatives --set $bin /usr/bin/python$PYMAJOR-$bin + done + rm -rf .testrepository + testr-python$PYMAJOR init + TEMP_REZ=`mktemp -t` + PYTHONPATH=`pwd` PYTHON=python$i testr-python$PYMAJOR run --subunit | tee $TEMP_REZ | subunit2pyunit ; \ + cat $TEMP_REZ | subunit-filter -s --no-passthrough | subunit-stats ; \ + rm -f $TEMP_REZ ; \ + testr-python$PYMAJOR slowest ; \ +done