Skip to content

Commit 4d2bbfe

Browse files
sseliverstovGilBecker-Anaplan
authored andcommitted
rename allure-commons-testing (fixes allure-framework#74 via allure-framework#84)
* rename allure-commons-testing * fix jenkins file
1 parent 4f8c47a commit 4d2bbfe

19 files changed

Lines changed: 61 additions & 644 deletions

File tree

Jenkinsfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ pipeline {
66
stages {
77
stage("Build") {
88
steps {
9-
sh 'tox --version'
9+
sh 'tox --workdir=/tmp -c allure-python-commons-test/tox.ini'
1010
sh 'tox --workdir=/tmp -c allure-python-commons/tox.ini'
11-
sh 'tox --workdir=/tmp -c allure-python-testing/tox.ini'
1211
sh 'tox --workdir=/tmp -c allure-pytest/tox.ini'
1312
sh 'tox --workdir=/tmp -c allure-behave/tox.ini'
1413
}

allure-behave/features/steps/behave_steps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
from tempfile import mkdtemp
3-
from allure_testing.report import AllureReport
3+
from allure_commons_test.report import AllureReport
44
from behave.parser import Parser
55
from behave.runner import ModelRunner
66
from behave.configuration import Configuration

allure-behave/features/steps/report_steps.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
from functools import partial
22
from hamcrest import assert_that
3-
from allure_testing.report import has_test_case
4-
from allure_testing.result import with_status
5-
from allure_testing.result import has_step
6-
from allure_testing.result import has_attachment
7-
from allure_testing.result import has_parameter
8-
from allure_testing.container import has_container
9-
from allure_testing.container import has_before
10-
from allure_testing.label import has_severity
11-
from allure_testing.label import has_tag
3+
from allure_commons_test.report import has_test_case
4+
from allure_commons_test.result import with_status
5+
from allure_commons_test.result import has_step
6+
from allure_commons_test.result import has_attachment
7+
from allure_commons_test.result import has_parameter
8+
from allure_commons_test.container import has_container
9+
from allure_commons_test.container import has_before
10+
from allure_commons_test.label import has_severity
11+
from allure_commons_test.label import has_tag
1212

1313

1414
def match(matcher, *args):

allure-behave/tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ setenv =
1515
whitelist_externals = rm
1616

1717
deps=
18-
{distshare}/allure-python-commons-*.zip
19-
{distshare}/allure-python-testing-*.zip
18+
{distshare}/allure-python-commons-2*.zip
19+
{distshare}/allure-python-commons-test-2*.zip
2020

2121
commands=
2222
python setup.py develop

allure-pytest/test/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import subprocess
44
import shlex
55
from inspect import getmembers, isfunction
6-
from allure_testing.report import AllureReport
6+
from allure_commons_test.report import AllureReport
77

88

99
@pytest.fixture(scope='function', autouse=True)
@@ -12,7 +12,7 @@ def inject_matchers(doctest_namespace):
1212
for name, function in getmembers(hamcrest, isfunction):
1313
doctest_namespace[name] = function
1414

15-
from allure_testing import container, label, report, result
15+
from allure_commons_test import container, label, report, result
1616
for module in [container, label, report, result]:
1717
for name, function in getmembers(module, isfunction):
1818
doctest_namespace[name] = function

allure-pytest/tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ whitelist_externals = rm
1212

1313
deps=
1414
pyhamcrest
15-
{distshare}/allure-python-commons-*.zip
16-
{distshare}/allure-python-testing-*.zip
15+
{distshare}/allure-python-commons-2*.zip
16+
{distshare}/allure-python-commons-test-2*.zip
1717

1818
commands=
1919
python setup.py develop

allure-python-commons-test/setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from setuptools import setup
22

33
PACKAGE = "allure-python-commons-test"
4+
VERSION = "2.0.0b2"
45

56
install_requires = [
67
"pyhamcrest>=1.9.0",
@@ -11,10 +12,9 @@
1112
def main():
1213
setup(
1314
name=PACKAGE,
14-
use_scm_version={"root": "..", "relative_to": __file__},
15-
setup_requires=['setuptools_scm'],
15+
version=VERSION,
1616
description="Common module for self-testing allure integrations with python-based frameworks",
17-
url="https://github.com/allure-framework/allure-python",
17+
url="https://github.com/allure-framework/allure-python2",
1818
author="QAMetaSoftware, Stanislav Seliverstov",
1919
author_email="sseliverstov@qameta.io",
2020
license="Apache-2.0",

allure-python-commons-test/src/container.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ def describe_mismatch(self, item, mismatch_descaription):
2828

2929
def has_container(report, *matchers):
3030
"""
31-
>>> from hamcrest import assert_that
32-
33-
>>> from allure_commons_test.report import has_test_case
34-
3531
>>> class Report(object):
3632
... test_cases = [
3733
... {
@@ -64,7 +60,7 @@ def has_container(report, *matchers):
6460
... has_before('before_fixture')
6561
... )
6662
... )
67-
... ) # doctest: +ELLIPSIS
63+
... )
6864
Traceback (most recent call last):
6965
...
7066
AssertionError: ...
@@ -108,8 +104,6 @@ def describe_to(self, description):
108104

109105
def has_same_container(*args):
110106
"""
111-
>>> from hamcrest import assert_that
112-
113107
>>> class Report(object):
114108
... test_cases = [
115109
... {
@@ -140,7 +134,7 @@ def has_same_container(*args):
140134
141135
>>> assert_that(Report,
142136
... has_same_container('second_test_case', 'third_test_case')
143-
... ) # doctest: +ELLIPSIS
137+
... )
144138
Traceback (most recent call last):
145139
...
146140
AssertionError: ...
Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""
2+
No milk today my love has gone away;)
3+
"""
4+
15
from hamcrest import all_of
26
from hamcrest import has_entry, has_item
37

@@ -16,10 +20,6 @@ def has_severity(level):
1620
return has_label('severity', level)
1721

1822

19-
def has_epic(feature):
20-
return has_label('epic', feature)
21-
22-
2323
def has_feature(feature):
2424
return has_label('feature', feature)
2525

@@ -29,20 +29,4 @@ def has_story(story):
2929

3030

3131
def has_tag(tag):
32-
return has_label('tag', tag)
33-
34-
35-
def has_package(package):
36-
return has_label('package', package)
37-
38-
39-
def has_suite(suite):
40-
return has_label('suite', suite)
41-
42-
43-
def has_parent_suite(parent_suite):
44-
return has_label('parentSuite', parent_suite)
45-
46-
47-
def has_sub_suite(sub_suite):
48-
return has_label('subSuite', sub_suite)
32+
return has_label('tag', tag)
Lines changed: 19 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
"""
2-
>>> from hamcrest import assert_that
3-
42
>>> class Report(object):
53
... def __init__(self):
64
... self.test_cases = [
@@ -36,7 +34,7 @@
3634
3735
>>> assert_that(Report(),
3836
... has_test_case('wrong_test_case_name')
39-
... ) # doctest: +ELLIPSIS
37+
... )
4038
Traceback (most recent call last):
4139
...
4240
AssertionError: ...
@@ -56,7 +54,7 @@
5654
... has_test_case('Class#test[param]',
5755
... has_entry('id', '2')
5856
... )
59-
... ) # doctest: +ELLIPSIS
57+
... )
6058
Traceback (most recent call last):
6159
...
6260
AssertionError: ...
@@ -66,98 +64,39 @@
6664
6765
"""
6866

69-
import sys
7067
import os
7168
import json
7269
import fnmatch
7370
from hamcrest import all_of, any_of
7471
from hamcrest import has_property
7572
from hamcrest import has_item
7673
from hamcrest import has_entry
77-
from hamcrest import ends_with, starts_with
78-
from hamcrest import only_contains
79-
from hamcrest.core.base_matcher import BaseMatcher
80-
81-
if sys.version_info[0] < 3:
82-
from io import open
74+
from hamcrest import ends_with
8375

8476

8577
class AllureReport(object):
86-
def __init__(self, result):
87-
self.result_dir = result
88-
self.test_cases = [json.load(item) for item in self._report_items(result, '*result.json')]
89-
self.test_containers = [json.load(item) for item in self._report_items(result, '*container.json')]
90-
self.attachments = [item.read() for item in self._report_items(result, '*attachment.*')]
91-
92-
@staticmethod
93-
def _report_items(report_dir, glob):
94-
for _file in os.listdir(report_dir):
78+
def __init__(self, report_dir):
79+
self.report_dir = report_dir
80+
self.test_cases = [json.load(item) for item in self._report_items('*result.json')]
81+
self.test_containers = [json.load(item) for item in self._report_items('*container.json')]
82+
self.attachments = [item.read() for item in self._report_items('*attachment.*')]
83+
84+
def _report_items(self, glob):
85+
for _file in os.listdir(self.report_dir):
9586
if fnmatch.fnmatch(_file, glob):
96-
with open(os.path.join(report_dir, _file), encoding="utf-8") as report_file:
87+
with open(os.path.join(self.report_dir, _file)) as report_file:
9788
yield report_file
9889

9990

10091
def has_test_case(name, *matchers):
10192
return has_property('test_cases',
10293
has_item(
103-
all_of(
104-
any_of(
105-
has_entry('fullName', ends_with(name)),
106-
has_entry('name', starts_with(name))
107-
),
108-
*matchers
109-
)
110-
)
111-
)
112-
113-
114-
class HasOnlyTetcases(BaseMatcher):
115-
def __init__(self, *matchers):
116-
self.matchers = matchers
117-
118-
def _matches(self, item):
119-
return has_property('test_cases',
120-
only_contains(any_of(*self.matchers))
121-
).matches(item)
122-
123-
def describe_to(self, description):
124-
pass
125-
126-
127-
def has_only_testcases(*matchers):
128-
return HasOnlyTetcases(*matchers)
129-
130-
131-
class ContainsExactly(BaseMatcher):
132-
def __init__(self, num, matcher):
133-
self.matcher = matcher
134-
self.count = 0
135-
self.num = num
136-
137-
def _matches(self, item):
138-
self.count = 0
139-
for subitem in item:
140-
if self.matcher.matches(subitem):
141-
self.count += 1
142-
143-
if self.count == self.num:
144-
return True
145-
else:
146-
return False
147-
148-
def describe_to(self, description):
149-
description.append_text('exactly {} item(s) matching '.format(self.num)).append_text(self.matcher)
150-
151-
152-
def has_only_n_test_cases(name, num, *matchers):
153-
return has_property('test_cases',
154-
ContainsExactly(num,
155-
all_of(
156-
any_of(
157-
has_entry('fullName', ends_with(name)),
158-
has_entry('name', ends_with(name))
159-
),
160-
*matchers
161-
)
94+
all_of(
95+
any_of(
96+
has_entry('fullName', ends_with(name)),
97+
has_entry('name', ends_with(name))
98+
),
99+
*matchers
162100
)
101+
)
163102
)

0 commit comments

Comments
 (0)