From 7eb7a12a512a32bfdac52c0df0b00acb05554e2f Mon Sep 17 00:00:00 2001 From: Stas Seliverstov Date: Thu, 19 Oct 2017 14:53:22 +0300 Subject: [PATCH] can work with behave from master branch (aka 1.2.6) now --- allure-behave/setup.py | 2 +- allure-behave/src/listener.py | 5 +--- allure-behave/src/utils.py | 8 ++++-- allure-behave/tox.ini | 45 ++++++++++++++++++++++++------ allure-pytest/tox.ini | 35 ++++++++++------------- allure-python-commons-test/tox.ini | 6 ++-- allure-python-commons/tox.ini | 11 +++----- 7 files changed, 64 insertions(+), 48 deletions(-) diff --git a/allure-behave/setup.py b/allure-behave/setup.py index 3a798c98..2e057a6a 100644 --- a/allure-behave/setup.py +++ b/allure-behave/setup.py @@ -13,7 +13,7 @@ ] install_requires = [ - "behave==1.2.5", + "behave>=1.2.5", "allure-python-commons==2.2.3b1" ] diff --git a/allure-behave/src/listener.py b/allure-behave/src/listener.py index 4a3e8ea8..1aaaf5f2 100644 --- a/allure-behave/src/listener.py +++ b/allure-behave/src/listener.py @@ -11,7 +11,7 @@ from allure_commons.model2 import TestStepResult from allure_commons.model2 import TestBeforeResult, TestAfterResult from allure_commons.model2 import TestResultContainer -from allure_commons.model2 import Status, Parameter, Label +from allure_commons.model2 import Parameter, Label from allure_behave.utils import scenario_parameters from allure_behave.utils import scenario_severity from allure_behave.utils import scenario_tags @@ -23,7 +23,6 @@ from allure_behave.utils import get_status, get_status_details - BEFORE_FIXTURES = ['before_all', 'before_tag', 'before_feature', 'before_scenario'] AFTER_FIXTURES = ['after_all', 'after_tag', 'after_feature', 'after_scenario'] FIXTURES = BEFORE_FIXTURES + AFTER_FIXTURES @@ -162,7 +161,6 @@ def stop_step(self, uuid, exc_type, exc_val, exc_tb): status=get_status(exc_val), statusDetails=get_status_details(exc_type, exc_val, exc_tb)) - @allure_commons.hookimpl def attach_data(self, body, name, attachment_type, extension): self.logger.attach_data(uuid4(), body, name=name, attachment_type=attachment_type, extension=extension) @@ -185,4 +183,3 @@ def enter(self, _list=list()): def exit(self): gone, self[:] = self[:], self._stack.pop() return gone - diff --git a/allure-behave/src/utils.py b/allure-behave/src/utils.py index a7c772c5..e1793d57 100644 --- a/allure-behave/src/utils.py +++ b/allure-behave/src/utils.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals +from enum import Enum from behave.model import ScenarioOutline from behave.runner_util import make_undefined_step_snippet from allure_commons.types import Severity -from allure_commons.model2 import Status, Parameter, Label +from allure_commons.model2 import Status, Parameter from allure_commons.model2 import StatusDetails from allure_commons.utils import md5 from allure_commons.utils import format_exception, format_traceback @@ -74,7 +75,10 @@ def step_status(result): if result.exception: return get_status(result.exception) else: - return STATUS.get(result.status, None) + if isinstance(result.status, Enum): + return STATUS.get(result.status.name, None) + else: + return STATUS.get(result.status, None) def get_status(exception): diff --git a/allure-behave/tox.ini b/allure-behave/tox.ini index 8b705240..09ef1db1 100644 --- a/allure-behave/tox.ini +++ b/allure-behave/tox.ini @@ -1,16 +1,34 @@ [tox] -envlist= +envlist = py{27,33,34,35} static_check [testenv] -passenv = - HOME +passenv = HOME setenv = TEST_TMP={envtmpdir} ALLURE_INDENT_OUTPUT=yep +whitelist_externals = rm + +deps= + {distshare}/allure-python-commons-2*.zip + {distshare}/allure-python-commons-test-2*.zip + +commands= + rm -rf {envtmpdir}/* + behave -f allure_behave.formatter:AllureFormatter -o {envtmpdir}/allrue-result -f pretty {posargs: ./features} + + +[testenv:behave-master] +passenv = HOME + +basepython = python3.5 + +setenv = + TEST_TMP={envtmpdir} + ALLURE_INDENT_OUTPUT=yep whitelist_externals = rm @@ -19,14 +37,14 @@ deps= {distshare}/allure-python-commons-test-2*.zip commands= - python setup.py develop + pip uninstall -y behave + pip install git+git://github.com/behave/behave.git rm -rf {envtmpdir}/* behave -f allure_behave.formatter:AllureFormatter -o {envtmpdir}/allrue-result -f pretty {posargs: ./features} [testenv:demo] -passenv = - HOME +passenv = HOME setenv = ALLURE_INDENT_OUTPUT=yep @@ -37,9 +55,18 @@ whitelist_externals = mkdir bash -commands= - python setup.py develop +commands = rm -rf {envtmpdir}/* - behave -v {posargs: ./features} mkdir {envtmpdir}/demo - bash -c 'find {envtmpdir}/ -type f -exec cp -rfp \{\} {envtmpdir}/demo/ \;' \ No newline at end of file + bash -c 'find {envtmpdir}/ -type f -exec cp -rfp \{\} {envtmpdir}/demo/ \;' + + +[testenv:static_check] +deps = flake8 + +commands = flake8 src/ + + +[flake8] +max-line-length = 120 \ No newline at end of file diff --git a/allure-pytest/tox.ini b/allure-pytest/tox.ini index 24047570..7add0df5 100644 --- a/allure-pytest/tox.ini +++ b/allure-pytest/tox.ini @@ -1,41 +1,39 @@ [tox] -envlist= +envlist = py{27,33,34,35} xdist static_check [testenv] -passenv = - HOME +passenv = HOME whitelist_externals = rm -deps= +deps = pyhamcrest {distshare}/allure-python-commons-2*.zip {distshare}/allure-python-commons-test-2*.zip -commands= - python setup.py develop +commands = rm -f {envtmpdir}/*.json py.test --doctest-module --alluredir={envtmpdir} {posargs: ./test/} [testenv:xdist] -passenv = - HOME +passenv = HOME + +basepython = python3.5 whitelist_externals = rm -deps= +deps = pyhamcrest pytest-xdist {distshare}/allure-python-commons-2*.zip {distshare}/allure-python-commons-test-2*.zip -commands= - python setup.py develop +commands = rm -f {envtmpdir}/*.json py.test -n 4 --doctest-module --alluredir={envtmpdir} {posargs: ./test/} @@ -46,27 +44,22 @@ commands= # `tox -e demo -- -k test_single_feature_label` or # `tox -e demo -- ./test/steps/` [testenv:demo] -passenv = - HOME +passenv = HOME whitelist_externals = rm -setenv = - ALLURE_INDENT_OUTPUT=yep +setenv = ALLURE_INDENT_OUTPUT=yep commands= - python setup.py develop rm -f {envtmpdir}/*.json - py.test -v --alluredir={envtmpdir} {posargs: ./test/} [testenv:static_check] -deps= - flake8 +deps = flake8 -commands= - flake8 src/ +commands = flake8 src/ [flake8] -max-line-length=120 \ No newline at end of file +max-line-length = 120 \ No newline at end of file diff --git a/allure-python-commons-test/tox.ini b/allure-python-commons-test/tox.ini index 25163f72..4bf3040e 100644 --- a/allure-python-commons-test/tox.ini +++ b/allure-python-commons-test/tox.ini @@ -1,11 +1,9 @@ [tox] -envlist= - py{27,33,34,35} +envlist = py{27,33,34,35} [testenv] -passenv = - HOME +passenv = HOME commands= python setup.py develop diff --git a/allure-python-commons/tox.ini b/allure-python-commons/tox.ini index cac7fc9c..5f6e3d1a 100644 --- a/allure-python-commons/tox.ini +++ b/allure-python-commons/tox.ini @@ -5,8 +5,7 @@ envlist= [testenv] -passenv = - HOME +passenv = HOME deps= pytest @@ -18,12 +17,10 @@ commands= [testenv:static_check] -deps= - flake8 +deps = flake8 -commands= - flake8 src/ +commands = flake8 src/ [flake8] -max-line-length=120 \ No newline at end of file +max-line-length = 120 \ No newline at end of file