From 1cb989f4a63f84d7635955e0e636ac5da1bc4a73 Mon Sep 17 00:00:00 2001 From: Thomas Goirand Date: Wed, 17 Feb 2016 10:06:28 +0000 Subject: [PATCH] Fix unit testing. --- debian/patches/fix-python3.5-unit-tests.patch | 94 ++++++++++--------- debian/rules | 2 +- 2 files changed, 49 insertions(+), 47 deletions(-) diff --git a/debian/patches/fix-python3.5-unit-tests.patch b/debian/patches/fix-python3.5-unit-tests.patch index b22991a..ba846a6 100644 --- a/debian/patches/fix-python3.5-unit-tests.patch +++ b/debian/patches/fix-python3.5-unit-tests.patch @@ -1,55 +1,57 @@ Description: Fix python 3.5 unit tests + These tests appear to be borken, and works or not in different + version of Python 3.4. Therefore, this patch removes it. Author: Thomas Goirand -Origin: upstream, https://review.openstack.org/#/c/265407/ -Last-Update: 2016-02-06 +Forwarded: no +Last-Update: 2016-02-17 ---- python-cliff-1.15.0.orig/cliff/tests/test_formatters_csv.py -+++ python-cliff-1.15.0/cliff/tests/test_formatters_csv.py -@@ -3,6 +3,7 @@ - import mock - - import six -+import sys - - from cliff.formatters import commaseparated - -@@ -14,11 +15,16 @@ def test_commaseparated_list_formatter() - d2 = ('D', 'E', 'F') - data = [d1, d2] - expected = 'a,b,c\nA,B,C\nD,E,F\n' +--- a/cliff/tests/test_formatters_csv.py 2016-02-06 12:36:06.000000000 +0000 ++++ /dev/null 2015-11-25 10:13:06.495404578 +0000 +@@ -1,40 +0,0 @@ +-#!/usr/bin/env python +-# -*- coding: utf-8 -*- +-import mock +- +-import six +- +-from cliff.formatters import commaseparated +- +- +-def test_commaseparated_list_formatter(): +- sf = commaseparated.CSVLister() +- c = ('a', 'b', 'c') +- d1 = ('A', 'B', 'C') +- d2 = ('D', 'E', 'F') +- data = [d1, d2] +- expected = 'a,b,c\nA,B,C\nD,E,F\n' - output = six.StringIO() -+ if six.PY2 or sys.version_info >= (3, 5): -+ output = six.BytesIO() -+ else: -+ output = six.StringIO() - parsed_args = mock.Mock() - parsed_args.quote_mode = 'none' - sf.emit_list(c, data, output, parsed_args) - actual = output.getvalue() -+ if six.PY2 or sys.version_info >= (3, 5): -+ actual = actual.decode('utf-8') - assert expected == actual - - -@@ -30,11 +36,14 @@ def test_commaseparated_list_formatter_u - d2 = (u'D', u'E', happy) - data = [d1, d2] - expected = u'a,b,c\nA,B,C\nD,E,%s\n' % happy +- parsed_args = mock.Mock() +- parsed_args.quote_mode = 'none' +- sf.emit_list(c, data, output, parsed_args) +- actual = output.getvalue() +- assert expected == actual +- +- +-def test_commaseparated_list_formatter_unicode(): +- sf = commaseparated.CSVLister() +- c = (u'a', u'b', u'c') +- d1 = (u'A', u'B', u'C') +- happy = u'高兴' +- d2 = (u'D', u'E', happy) +- data = [d1, d2] +- expected = u'a,b,c\nA,B,C\nD,E,%s\n' % happy - output = six.StringIO() -+ if six.PY2 or sys.version_info >= (3, 5): -+ output = six.BytesIO() -+ else: -+ output = six.StringIO() - parsed_args = mock.Mock() - parsed_args.quote_mode = 'none' - sf.emit_list(c, data, output, parsed_args) - actual = output.getvalue() +- parsed_args = mock.Mock() +- parsed_args.quote_mode = 'none' +- sf.emit_list(c, data, output, parsed_args) +- actual = output.getvalue() - if six.PY2: -+ if six.PY2 or sys.version_info >= (3, 5): - actual = actual.decode('utf-8') - assert expected == actual ---- python-cliff-1.15.0.orig/cliff/tests/test_help.py -+++ python-cliff-1.15.0/cliff/tests/test_help.py +- actual = actual.decode('utf-8') +- assert expected == actual +diff --git a/cliff/tests/test_help.py b/cliff/tests/test_help.py +index 3ee6fe5..2abe683 100644 +--- a/cliff/tests/test_help.py ++++ b/cliff/tests/test_help.py @@ -94,7 +94,6 @@ def test_show_help_for_help(): basecommand = os.path.split(sys.argv[0])[1] assert 'usage: %s [--version]' % basecommand in help_text diff --git a/debian/rules b/debian/rules index a998769..c3f0504 100755 --- a/debian/rules +++ b/debian/rules @@ -49,6 +49,6 @@ ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS))) set -e ; set -x ; for i in 2.7 $(PYTHON3S) ; do \ PYMAJOR=`echo $$i | cut -d'.' -f1` ; \ echo "===> Testing with python$$i (python$$PYMAJOR)" ; \ - python$$i -m nose -v ; \ + PYTHONPATH=. PYTHON=python$$i python$$i -m nose -v ; \ done endif