fix: allure ModuleNotFoundError

This commit is contained in:
debugtalk
2020-05-28 18:58:49 +08:00
parent 63925b9c25
commit e45c83cb5f
+10
View File
@@ -4,7 +4,13 @@ import uuid
from datetime import datetime
from typing import List, Dict, Text
try:
import allure
USE_ALLURE = True
except ModuleNotFoundError:
USE_ALLURE = False
from loguru import logger
from httprunner import utils, exceptions
@@ -236,8 +242,11 @@ class HttpRunner(object):
step.variables, self.__project_meta.functions
)
# run step
if USE_ALLURE:
with allure.step(f"step: {step.name}"):
extract_mapping = self.__run_step(step)
else:
extract_mapping = self.__run_step(step)
# save extracted variables to session variables
self.__session_variables.update(extract_mapping)
@@ -312,6 +321,7 @@ class HttpRunner(object):
self.config.name, variables, self.__project_meta.functions
)
if USE_ALLURE:
# update allure report meta
allure.dynamic.title(self.config.name)
allure.dynamic.description(f"TestCase ID: {self.__case_id}")