Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bbe1ee9

Browse files
authored
Remove old python2-related code and add python 3.11 support (#715)
1 parent 3f113fe commit bbe1ee9

File tree

73 files changed

+408
-578
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+408
-578
lines changed

.github/workflows/build.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@ jobs:
1616
id: filter
1717
with:
1818
filters: |
19-
allure-behave:
19+
allure-behave:
2020
- allure-behave/**
2121
- allure-python-commons/**
2222
- allure-python-commons-test/**
23-
allure-nose2:
23+
allure-nose2:
2424
- allure-nose2/**
2525
- allure-python-commons/**
2626
- allure-python-commons-test/**
27-
allure-pytest:
27+
allure-pytest:
2828
- allure-pytest/**
2929
- allure-python-commons/**
3030
- allure-python-commons-test/**
31-
allure-pytest-bdd:
31+
allure-pytest-bdd:
3232
- allure-pytest-bdd/**
3333
- allure-python-commons/**
3434
- allure-python-commons-test/**
35-
allure-robotframework:
35+
allure-robotframework:
3636
- allure-robotframework/**
3737
- allure-python-commons/**
3838
- allure-python-commons-test/**
@@ -72,7 +72,7 @@ jobs:
7272
- name: Set up Python
7373
uses: actions/setup-python@v4
7474
with:
75-
python-version: "3.10"
75+
python-version: "3.11"
7676

7777
- name: Get commons from cache
7878
id: commons
@@ -98,7 +98,7 @@ jobs:
9898
strategy:
9999
matrix:
100100
package: ${{ fromJSON(needs.changes.outputs.packages) }}
101-
python-version: [3.7, 3.8, 3.9, "3.10"]
101+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
102102
env:
103103
TEST_TMP: /tmp
104104
ALLURE_INDENT_OUTPUT: yep

.github/workflows/release.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,18 @@ jobs:
99
runs-on: ubuntu-latest
1010

1111
steps:
12-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v3
13+
1314
- name: Set up Python
14-
uses: actions/setup-python@v1
15+
uses: actions/setup-python@v4
1516
with:
1617
python-version: '3.x'
1718

1819
- name: Install dependencies
1920
run: |
2021
python -m pip install --upgrade pip
2122
pip install setuptools wheel twine
22-
23+
2324
- name: Build and publish
2425
env:
2526
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}

allure-behave/features/steps/behave_steps.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
from contextlib import contextmanager
1212

1313

14-
@given(u'feature definition')
15-
@given(u'feature definition {lang}')
14+
@given('feature definition')
15+
@given('feature definition {lang}')
1616
def feature_definition(context, **kwargs):
1717
parser = Parser(language=kwargs.get('lang', None))
1818
feature = parser.parse(context.text)
@@ -22,13 +22,13 @@ def feature_definition(context, **kwargs):
2222
context.feature_definition = [feature]
2323

2424

25-
@given(u'hooks implementation')
25+
@given('hooks implementation')
2626
def hooks_implementations(context):
2727
context.globals = {}
2828
exec(context.text, context.globals)
2929

3030

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

4040

41-
@when(u'I run behave with allure formatter')
42-
@when(u'I run behave with allure formatter with options "{args}"')
41+
@when('I run behave with allure formatter')
42+
@when('I run behave with allure formatter with options "{args}"')
4343
def run_behave_with_allure(context, **kwargs):
4444
with test_context():
4545
cmd_args = '-f allure_behave.formatter:AllureFormatter'
46-
cmd = '{options} {cmd}'.format(cmd=cmd_args, options=kwargs.get('args', ''))
46+
cmd_options = kwargs.get('args', '')
47+
cmd = f'{cmd_options} {cmd_args}'
4748
config = Configuration(command_args=cmd)
4849
result_tmp_dir = mkdtemp(dir=os.environ.get('TEST_TMP', None))
4950
stream_opener = StreamOpener(filename=result_tmp_dir)
Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,49 @@
1-
# -*- coding: utf-8 -*-
2-
31
import allure
42
from behave import given
53

64

7-
@given(u'passed step')
8-
@given(u'{what} passed step')
9-
@given(u'passed step {where}')
10-
@given(u'{what} passed step {where}')
5+
@given('passed step')
6+
@given('{what} passed step')
7+
@given('passed step {where}')
8+
@given('{what} passed step {where}')
119
def step_impl(*args, **kwargs):
1210
if 'with attachment' in kwargs.values():
1311
allure.attach('Hi there!', name='user attachment', attachment_type=allure.attachment_type.TEXT)
1412
pass
1513

1614

17-
@given(u'failed step')
18-
@given(u'{what} failed step')
19-
@given(u'failed step {where}')
20-
@given(u'{what} failed step {where}')
15+
@given('failed step')
16+
@given('{what} failed step')
17+
@given('failed step {where}')
18+
@given('{what} failed step {where}')
2119
def step_impl(*args, **kwargs):
2220
assert False, 'Assert message'
2321

2422

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

2927

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

3432

35-
@given(u'проходящий шаг')
33+
@given('проходящий шаг')
3634
def step_impl(*args, **kwargs):
3735
pass
3836

3937

40-
@given(u'broken step')
41-
@given(u'{what} broken step')
42-
@given(u'broken step {where}')
43-
@given(u'{what} broken step {where}')
38+
@given('broken step')
39+
@given('{what} broken step')
40+
@given('broken step {where}')
41+
@given('{what} broken step {where}')
4442
def step_impl(*args, **kwargs):
4543
raise ZeroDivisionError()
4644

4745

48-
@given(u'всегда будет <это>')
49-
@given(u'всегда буду я')
46+
@given('всегда будет <это>')
47+
@given('всегда буду я')
5048
def step_impl(*args, **kwargs):
5149
pass

allure-behave/features/steps/report_steps.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,132 +27,132 @@ def match(matcher, *args):
2727
return matcher()
2828

2929

30-
@then(u'allure report has a scenario with name "{scenario}"')
30+
@then('allure report has a scenario with name "{scenario}"')
3131
def step_scenario(context, scenario):
3232
matcher = partial(match, has_test_case, scenario)
3333
context.scenario = matcher
3434
assert_that(context.allure_report, matcher())
3535

3636

37-
@then(u'allure report has not a scenario with name "{scenario}"')
37+
@then('allure report has not a scenario with name "{scenario}"')
3838
def step_scenario(context, scenario):
3939
matcher = partial(match, not_, has_test_case, scenario)
4040
context.scenario = matcher
4141
assert_that(context.allure_report, matcher())
4242

4343

44-
@then(u'scenario has before fixture "{fixture}"')
45-
@then(u'this scenario has before fixture "{fixture}"')
44+
@then('scenario has before fixture "{fixture}"')
45+
@then('this scenario has before fixture "{fixture}"')
4646
def step_before_fixture(context, fixture):
4747
context_matcher = context.scenario
4848
matcher = partial(context_matcher, has_container, context.allure_report, has_before, fixture)
4949
context.before = matcher
5050
assert_that(context.allure_report, matcher())
5151

5252

53-
@then(u'scenario has after fixture "{fixture}"')
54-
@then(u'this scenario has after fixture "{fixture}"')
53+
@then('scenario has after fixture "{fixture}"')
54+
@then('this scenario has after fixture "{fixture}"')
5555
def step_after_fixture(context, fixture):
5656
context_matcher = context.scenario
5757
matcher = partial(context_matcher, has_container, context.allure_report, has_after, fixture)
5858
context.after = matcher
5959
assert_that(context.allure_report, matcher())
6060

6161

62-
@then(u'scenario has not before fixture "{fixture}"')
63-
@then(u'this scenario has not before fixture "{fixture}"')
62+
@then('scenario has not before fixture "{fixture}"')
63+
@then('this scenario has not before fixture "{fixture}"')
6464
def step_no_before_fixture(context, fixture):
6565
context_matcher = context.scenario
6666
matcher = partial(context_matcher, not_, has_container, context.allure_report, has_before, fixture)
6767
assert_that(context.allure_report, matcher())
6868

6969

70-
@then(u'scenario has not after fixture "{fixture}"')
71-
@then(u'this scenario has not after fixture "{fixture}"')
70+
@then('scenario has not after fixture "{fixture}"')
71+
@then('this scenario has not after fixture "{fixture}"')
7272
def step_impl(context, fixture):
7373
context_matcher = context.scenario
7474
matcher = partial(context_matcher, not_, has_container, context.allure_report, has_after, fixture)
7575
assert_that(context.allure_report, matcher())
7676

7777

78-
@then(u'{item} contains step "{step}"')
79-
@then(u'this {item} contains step "{step}"')
78+
@then('{item} contains step "{step}"')
79+
@then('this {item} contains step "{step}"')
8080
def step_step(context, item, step):
8181
context_matcher = getattr(context, item)
8282
matcher = partial(context_matcher, has_step, step)
8383
context.step = matcher
8484
assert_that(context.allure_report, matcher())
8585

8686

87-
@then(u'{item} has "{status}" status')
88-
@then(u'this {item} has "{status}" status')
87+
@then('{item} has "{status}" status')
88+
@then('this {item} has "{status}" status')
8989
def step_status(context, item, status):
9090
context_matcher = getattr(context, item)
9191
matcher = partial(context_matcher, with_status, status)
9292
assert_that(context.allure_report, matcher())
9393

9494

95-
@then(u'{item} has status details with message "{message}"')
96-
@then(u'this {item} has status details with message "{message}"')
95+
@then('{item} has status details with message "{message}"')
96+
@then('this {item} has status details with message "{message}"')
9797
def step_status(context, item, message):
9898
context_matcher = getattr(context, item)
9999
matcher = partial(context_matcher, has_status_details, with_message_contains, message)
100100
assert_that(context.allure_report, matcher())
101101

102102

103-
@then(u'scenario has "{severity}" severity')
104-
@then(u'this scenario has "{severity}" severity')
103+
@then('scenario has "{severity}" severity')
104+
@then('this scenario has "{severity}" severity')
105105
def step_severity(context, severity):
106106
context_matcher = context.scenario
107107
matcher = partial(context_matcher, has_severity, severity)
108108
assert_that(context.allure_report, matcher())
109109

110110

111-
@then(u'scenario has "{tag}" tag')
112-
@then(u'this scenario has "{tag}" tag')
111+
@then('scenario has "{tag}" tag')
112+
@then('this scenario has "{tag}" tag')
113113
def step_tag(context, tag):
114114
context_matcher = context.scenario
115115
matcher = partial(context_matcher, has_tag, tag)
116116
assert_that(context.allure_report, matcher())
117117

118118

119-
@then(u'scenario has "{url}" link')
120-
@then(u'this scenario has "{url}" link')
121-
@then(u'scenario has "{url}" link with type "{link_type}"')
122-
@then(u'this scenario has "{url}" link with type "{link_type}"')
123-
@then(u'scenario has "{url}" link with type "{link_type}" and name "{name}"')
124-
@then(u'this scenario has "{url}" link with type "{link_type}" and name "{name}"')
119+
@then('scenario has "{url}" link')
120+
@then('this scenario has "{url}" link')
121+
@then('scenario has "{url}" link with type "{link_type}"')
122+
@then('this scenario has "{url}" link with type "{link_type}"')
123+
@then('scenario has "{url}" link with type "{link_type}" and name "{name}"')
124+
@then('this scenario has "{url}" link with type "{link_type}" and name "{name}"')
125125
def step_link(context, url, link_type=None, name=None,):
126126
context_matcher = context.scenario
127127
matcher = partial(context_matcher, has_link, url, link_type, name)
128128
assert_that(context.allure_report, matcher())
129129

130130

131-
@then(u'scenario has "{name}" label with value "{value}"')
132-
@then(u'this scenario has "{name}" label with value "{value}"')
131+
@then('scenario has "{name}" label with value "{value}"')
132+
@then('this scenario has "{name}" label with value "{value}"')
133133
def step_label(context, name, value):
134134
context_matcher = context.scenario
135135
matcher = partial(context_matcher, has_label, name, value)
136136
assert_that(context.allure_report, matcher())
137137

138138

139-
@then(u'{item} has parameter "{name}" with value "{value}"')
140-
@then(u'this {item} has parameter "{name}" with value "{value}"')
139+
@then('{item} has parameter "{name}" with value "{value}"')
140+
@then('this {item} has parameter "{name}" with value "{value}"')
141141
def step_parameter(context, item, name, value):
142142
context_matcher = getattr(context, item)
143143
matcher = partial(context_matcher, has_parameter, name, value)
144144
assert_that(context.allure_report, matcher())
145145

146146

147-
@then(u'{item} has attachment')
148-
@then(u'this {item} has attachment')
147+
@then('{item} has attachment')
148+
@then('this {item} has attachment')
149149
def step_attachment(context, item):
150150
context_matcher = getattr(context, item)
151151
matcher = partial(context_matcher, has_attachment)
152152
assert_that(context.allure_report, matcher())
153153

154154

155-
@then(u'scenario has description "{description}"')
155+
@then('scenario has description "{description}"')
156156
def step_description(context, description):
157157
context_matcher = context.scenario
158158
matcher = partial(context_matcher, has_description, contains_string(description))

allure-behave/setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
'Programming Language :: Python :: 3.8',
1717
'Programming Language :: Python :: 3.9',
1818
'Programming Language :: Python :: 3.10',
19+
'Programming Language :: Python :: 3.11',
1920
]
2021

2122
setup_requires = [
@@ -31,7 +32,7 @@ def prepare_version():
3132
from setuptools_scm import get_version
3233
configuration = {"root": "..", "relative_to": __file__}
3334
version = get_version(**configuration)
34-
install_requires.append("allure-python-commons=={version}".format(version=version))
35+
install_requires.append(f"allure-python-commons=={version}")
3536
return configuration
3637

3738

allure-behave/src/hooks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def allure_report(result_dir="allure_results"):
3939
del frame
4040

4141

42-
class AllureHooks(object):
42+
class AllureHooks:
4343
def __init__(self, result_dir):
4444
self.listener = AllureListener(Configuration())
4545

0 commit comments

Comments
 (0)