diff --git a/openstack_dashboard/dashboards/project/containers/tests.py b/openstack_dashboard/dashboards/project/containers/tests.py index 109ed79547..90509ed1e3 100644 --- a/openstack_dashboard/dashboards/project/containers/tests.py +++ b/openstack_dashboard/dashboards/project/containers/tests.py @@ -17,6 +17,7 @@ # under the License. import copy +import email.header import tempfile from django.core.files.uploadedfile import InMemoryUploadedFile # noqa @@ -359,13 +360,18 @@ class SwiftTests(test.TestCase): # Check that the returned Content-Disposition filename is well # surrounded by double quotes and with commas removed + content = res.get('Content-Disposition') expected_name = '"%s"' % obj.name.replace(',', '') - if six.PY2: - expected_name = expected_name.encode('utf-8') - self.assertEqual( - res.get('Content-Disposition'), - 'attachment; filename=%s' % expected_name - ) + expected = 'attachment; filename=%s' % expected_name + + if six.PY3: + header = email.header.decode_header(content) + content = header[0][0] + if isinstance(content, str): + content = content.encode('utf-8') + expected = expected.encode('utf-8') + + self.assertEqual(content, expected) @test.create_stubs({api.swift: ('swift_get_containers',)}) def test_copy_index(self): diff --git a/tox.ini b/tox.ini index d00a5d6746..badcc63535 100644 --- a/tox.ini +++ b/tox.ini @@ -31,6 +31,7 @@ commands = openstack_dashboard.dashboards.admin.volumes.volumes.tests \ openstack_dashboard.dashboards.identity.users \ openstack_dashboard.dashboards.project.access_and_security.api_access.tests \ + openstack_dashboard.dashboards.project.containers \ openstack_dashboard.dashboards.project.images \ openstack_dashboard.dashboards.project.instances \ openstack_dashboard.dashboards.project.loadbalancers \