Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ jobs:
id: filter
with:
filters: |
allure-behave:
allure-behave:
- allure-behave/**
- allure-python-commons/**
- allure-python-commons-test/**
allure-nose2:
allure-nose2:
- allure-nose2/**
- allure-python-commons/**
- allure-python-commons-test/**
allure-pytest:
allure-pytest:
- allure-pytest/**
- allure-python-commons/**
- allure-python-commons-test/**
allure-pytest-bdd:
allure-pytest-bdd:
- allure-pytest-bdd/**
- allure-python-commons/**
- allure-python-commons-test/**
allure-robotframework:
allure-robotframework:
- allure-robotframework/**
- allure-python-commons/**
- allure-python-commons-test/**
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"

- name: Get commons from cache
id: commons
Expand All @@ -98,7 +98,7 @@ jobs:
strategy:
matrix:
package: ${{ fromJSON(needs.changes.outputs.packages) }}
python-version: [3.7, 3.8, 3.9, "3.10"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
env:
TEST_TMP: /tmp
ALLURE_INDENT_OUTPUT: yep
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine

- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
Expand Down
15 changes: 8 additions & 7 deletions allure-behave/features/steps/behave_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from contextlib import contextmanager


@given(u'feature definition')
@given(u'feature definition {lang}')
@given('feature definition')
@given('feature definition {lang}')
def feature_definition(context, **kwargs):
parser = Parser(language=kwargs.get('lang', None))
feature = parser.parse(context.text)
Expand All @@ -22,13 +22,13 @@ def feature_definition(context, **kwargs):
context.feature_definition = [feature]


@given(u'hooks implementation')
@given('hooks implementation')
def hooks_implementations(context):
context.globals = {}
exec(context.text, context.globals)


@given(u'test plan')
@given('test plan')
def test_plan_helper(context):
tmp_dir = os.environ.get("TEST_TMP")
file, filename = tempfile.mkstemp(suffix=".json", dir=tmp_dir)
Expand All @@ -38,12 +38,13 @@ def test_plan_helper(context):
context.test_plan = filename


@when(u'I run behave with allure formatter')
@when(u'I run behave with allure formatter with options "{args}"')
@when('I run behave with allure formatter')
@when('I run behave with allure formatter with options "{args}"')
def run_behave_with_allure(context, **kwargs):
with test_context():
cmd_args = '-f allure_behave.formatter:AllureFormatter'
cmd = '{options} {cmd}'.format(cmd=cmd_args, options=kwargs.get('args', ''))
cmd_options = kwargs.get('args', '')
cmd = f'{cmd_options} {cmd_args}'
config = Configuration(command_args=cmd)
result_tmp_dir = mkdtemp(dir=os.environ.get('TEST_TMP', None))
stream_opener = StreamOpener(filename=result_tmp_dir)
Expand Down
38 changes: 18 additions & 20 deletions allure-behave/features/steps/dummy_steps.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,49 @@
# -*- coding: utf-8 -*-

import allure
from behave import given


@given(u'passed step')
@given(u'{what} passed step')
@given(u'passed step {where}')
@given(u'{what} passed step {where}')
@given('passed step')
@given('{what} passed step')
@given('passed step {where}')
@given('{what} passed step {where}')
def step_impl(*args, **kwargs):
if 'with attachment' in kwargs.values():
allure.attach('Hi there!', name='user attachment', attachment_type=allure.attachment_type.TEXT)
pass


@given(u'failed step')
@given(u'{what} failed step')
@given(u'failed step {where}')
@given(u'{what} failed step {where}')
@given('failed step')
@given('{what} failed step')
@given('failed step {where}')
@given('{what} failed step {where}')
def step_impl(*args, **kwargs):
assert False, 'Assert message'


@given(u'провальный шаг')
@given('провальный шаг')
def step_impl(*args, **kwargs):
assert False, u'Фиаско!'
assert False, 'Фиаско!'


@given(u'провальный шаг с ascii')
@given('провальный шаг с ascii')
def step_impl(*args, **kwargs):
assert False, 'Фиаско!'


@given(u'проходящий шаг')
@given('проходящий шаг')
def step_impl(*args, **kwargs):
pass


@given(u'broken step')
@given(u'{what} broken step')
@given(u'broken step {where}')
@given(u'{what} broken step {where}')
@given('broken step')
@given('{what} broken step')
@given('broken step {where}')
@given('{what} broken step {where}')
def step_impl(*args, **kwargs):
raise ZeroDivisionError()


@given(u'всегда будет <это>')
@given(u'всегда буду я')
@given('всегда будет <это>')
@given('всегда буду я')
def step_impl(*args, **kwargs):
pass
66 changes: 33 additions & 33 deletions allure-behave/features/steps/report_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,132 +27,132 @@ def match(matcher, *args):
return matcher()


@then(u'allure report has a scenario with name "{scenario}"')
@then('allure report has a scenario with name "{scenario}"')
def step_scenario(context, scenario):
matcher = partial(match, has_test_case, scenario)
context.scenario = matcher
assert_that(context.allure_report, matcher())


@then(u'allure report has not a scenario with name "{scenario}"')
@then('allure report has not a scenario with name "{scenario}"')
def step_scenario(context, scenario):
matcher = partial(match, not_, has_test_case, scenario)
context.scenario = matcher
assert_that(context.allure_report, matcher())


@then(u'scenario has before fixture "{fixture}"')
@then(u'this scenario has before fixture "{fixture}"')
@then('scenario has before fixture "{fixture}"')
@then('this scenario has before fixture "{fixture}"')
def step_before_fixture(context, fixture):
context_matcher = context.scenario
matcher = partial(context_matcher, has_container, context.allure_report, has_before, fixture)
context.before = matcher
assert_that(context.allure_report, matcher())


@then(u'scenario has after fixture "{fixture}"')
@then(u'this scenario has after fixture "{fixture}"')
@then('scenario has after fixture "{fixture}"')
@then('this scenario has after fixture "{fixture}"')
def step_after_fixture(context, fixture):
context_matcher = context.scenario
matcher = partial(context_matcher, has_container, context.allure_report, has_after, fixture)
context.after = matcher
assert_that(context.allure_report, matcher())


@then(u'scenario has not before fixture "{fixture}"')
@then(u'this scenario has not before fixture "{fixture}"')
@then('scenario has not before fixture "{fixture}"')
@then('this scenario has not before fixture "{fixture}"')
def step_no_before_fixture(context, fixture):
context_matcher = context.scenario
matcher = partial(context_matcher, not_, has_container, context.allure_report, has_before, fixture)
assert_that(context.allure_report, matcher())


@then(u'scenario has not after fixture "{fixture}"')
@then(u'this scenario has not after fixture "{fixture}"')
@then('scenario has not after fixture "{fixture}"')
@then('this scenario has not after fixture "{fixture}"')
def step_impl(context, fixture):
context_matcher = context.scenario
matcher = partial(context_matcher, not_, has_container, context.allure_report, has_after, fixture)
assert_that(context.allure_report, matcher())


@then(u'{item} contains step "{step}"')
@then(u'this {item} contains step "{step}"')
@then('{item} contains step "{step}"')
@then('this {item} contains step "{step}"')
def step_step(context, item, step):
context_matcher = getattr(context, item)
matcher = partial(context_matcher, has_step, step)
context.step = matcher
assert_that(context.allure_report, matcher())


@then(u'{item} has "{status}" status')
@then(u'this {item} has "{status}" status')
@then('{item} has "{status}" status')
@then('this {item} has "{status}" status')
def step_status(context, item, status):
context_matcher = getattr(context, item)
matcher = partial(context_matcher, with_status, status)
assert_that(context.allure_report, matcher())


@then(u'{item} has status details with message "{message}"')
@then(u'this {item} has status details with message "{message}"')
@then('{item} has status details with message "{message}"')
@then('this {item} has status details with message "{message}"')
def step_status(context, item, message):
context_matcher = getattr(context, item)
matcher = partial(context_matcher, has_status_details, with_message_contains, message)
assert_that(context.allure_report, matcher())


@then(u'scenario has "{severity}" severity')
@then(u'this scenario has "{severity}" severity')
@then('scenario has "{severity}" severity')
@then('this scenario has "{severity}" severity')
def step_severity(context, severity):
context_matcher = context.scenario
matcher = partial(context_matcher, has_severity, severity)
assert_that(context.allure_report, matcher())


@then(u'scenario has "{tag}" tag')
@then(u'this scenario has "{tag}" tag')
@then('scenario has "{tag}" tag')
@then('this scenario has "{tag}" tag')
def step_tag(context, tag):
context_matcher = context.scenario
matcher = partial(context_matcher, has_tag, tag)
assert_that(context.allure_report, matcher())


@then(u'scenario has "{url}" link')
@then(u'this scenario has "{url}" link')
@then(u'scenario has "{url}" link with type "{link_type}"')
@then(u'this scenario has "{url}" link with type "{link_type}"')
@then(u'scenario has "{url}" link with type "{link_type}" and name "{name}"')
@then(u'this scenario has "{url}" link with type "{link_type}" and name "{name}"')
@then('scenario has "{url}" link')
@then('this scenario has "{url}" link')
@then('scenario has "{url}" link with type "{link_type}"')
@then('this scenario has "{url}" link with type "{link_type}"')
@then('scenario has "{url}" link with type "{link_type}" and name "{name}"')
@then('this scenario has "{url}" link with type "{link_type}" and name "{name}"')
def step_link(context, url, link_type=None, name=None,):
context_matcher = context.scenario
matcher = partial(context_matcher, has_link, url, link_type, name)
assert_that(context.allure_report, matcher())


@then(u'scenario has "{name}" label with value "{value}"')
@then(u'this scenario has "{name}" label with value "{value}"')
@then('scenario has "{name}" label with value "{value}"')
@then('this scenario has "{name}" label with value "{value}"')
def step_label(context, name, value):
context_matcher = context.scenario
matcher = partial(context_matcher, has_label, name, value)
assert_that(context.allure_report, matcher())


@then(u'{item} has parameter "{name}" with value "{value}"')
@then(u'this {item} has parameter "{name}" with value "{value}"')
@then('{item} has parameter "{name}" with value "{value}"')
@then('this {item} has parameter "{name}" with value "{value}"')
def step_parameter(context, item, name, value):
context_matcher = getattr(context, item)
matcher = partial(context_matcher, has_parameter, name, value)
assert_that(context.allure_report, matcher())


@then(u'{item} has attachment')
@then(u'this {item} has attachment')
@then('{item} has attachment')
@then('this {item} has attachment')
def step_attachment(context, item):
context_matcher = getattr(context, item)
matcher = partial(context_matcher, has_attachment)
assert_that(context.allure_report, matcher())


@then(u'scenario has description "{description}"')
@then('scenario has description "{description}"')
def step_description(context, description):
context_matcher = context.scenario
matcher = partial(context_matcher, has_description, contains_string(description))
Expand Down
3 changes: 2 additions & 1 deletion allure-behave/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
]

setup_requires = [
Expand All @@ -31,7 +32,7 @@ def prepare_version():
from setuptools_scm import get_version
configuration = {"root": "..", "relative_to": __file__}
version = get_version(**configuration)
install_requires.append("allure-python-commons=={version}".format(version=version))
install_requires.append(f"allure-python-commons=={version}")
return configuration


Expand Down
2 changes: 1 addition & 1 deletion allure-behave/src/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def allure_report(result_dir="allure_results"):
del frame


class AllureHooks(object):
class AllureHooks:
def __init__(self, result_dir):
self.listener = AllureListener(Configuration())

Expand Down
Loading