From 2df7840cfa8b0045ddf048e76c9b7c65ed1600b6 Mon Sep 17 00:00:00 2001 From: Cyril Roelandt Date: Tue, 4 Mar 2014 15:39:01 +0100 Subject: [PATCH] Python3: do not use the 'file' type It does not exist in Python 3, so we have to use a workaround. Change-Id: Ib41b5d12102707004b354835265861710aaba568 Closes-Bug: 1287728 --- tests/v1/test_shell.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/v1/test_shell.py b/tests/v1/test_shell.py index 72e38e8..39cb8d4 100644 --- a/tests/v1/test_shell.py +++ b/tests/v1/test_shell.py @@ -17,6 +17,7 @@ import argparse import json import os +import six import subprocess import tempfile import testtools @@ -30,6 +31,12 @@ import glanceclient.v1.shell as v1shell from tests import utils +if six.PY3: + import io + file_type = io.IOBase +else: + file_type = file + fixtures = { '/v1/images/96d2c7e1-de4e-4612-8aa2-ba26610c804e': { 'PUT': ( @@ -402,7 +409,7 @@ class ShellStdinHandlingTests(testtools.TestCase): self._do_update('44d2c7e1-de4e-4612-8aa2-ba26610c444f') self.assertTrue('data' in self.collected_args[1]) - self.assertIsInstance(self.collected_args[1]['data'], file) + self.assertIsInstance(self.collected_args[1]['data'], file_type) self.assertEqual(self.collected_args[1]['data'].read(), 'Some Data') @@ -427,7 +434,7 @@ class ShellStdinHandlingTests(testtools.TestCase): self._do_update('44d2c7e1-de4e-4612-8aa2-ba26610c444f') self.assertTrue('data' in self.collected_args[1]) - self.assertIsInstance(self.collected_args[1]['data'], file) + self.assertIsInstance(self.collected_args[1]['data'], file_type) self.assertEqual(self.collected_args[1]['data'].read(), 'Some Data\n')