From 4ab2877d1f583203a4e313dddf1a9bfd391ad4c1 Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Tue, 13 Jun 2017 16:31:41 +0000 Subject: [PATCH] HTML test report only when nosehtmloutput is installed Most horizon plugins import openstack_dashboard.test.settings in their test settings, but they do not necessarily have nosehtmloutput in test-reqs. Assuming nosehtmloutput potentially breaks plugins tests, we check the availability of htmloutput module (from nosehtmloutput) and specify --with-html-output option if available. Change-Id: I62502d28c75f823c47edb9de83932363cc2be99f Closes-Bug: #1697731 --- openstack_dashboard/test/settings.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/openstack_dashboard/test/settings.py b/openstack_dashboard/test/settings.py index 4f4e962c13..74b784735d 100644 --- a/openstack_dashboard/test/settings.py +++ b/openstack_dashboard/test/settings.py @@ -245,7 +245,16 @@ NOSE_ARGS = ['--nocapture', '--all-modules'] # TODO(amotoki): Need to investigate why --with-html-output # is unavailable in python3. -if six.PY2: +# NOTE(amotoki): Most horizon plugins import this module in their test +# settings and they do not necessarily have nosehtmloutput in test-reqs. +# Assuming nosehtmloutput potentially breaks plugins tests, +# we check the availability of htmloutput module (from nosehtmloutput). +try: + import htmloutput # noqa: F401 + has_html_output = True +except ImportError: + has_html_output = False +if six.PY2 and has_html_output: NOSE_ARGS += ['--with-html-output', '--html-out-file=ut_openstack_dashboard_nose_results.html']