Skip to content

Commit e2949f6

Browse files
author
Alexander.Iljushkin
authored
Merge pull request #34 from Sikamaru/33-exclude-tags
33 exclude tags
2 parents c1ba34f + 044f68e commit e2949f6

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

README.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Example of :code:`pytest.ini`:
4949
rp_launch_tags = 'PyTest' 'Smoke'
5050
rp_launch_description = 'Smoke test'
5151
rp_ignore_errors = True
52+
rp_ignore_tags = 'xfail' 'usefixture'
5253
5354
The following parameters are optional:
5455

@@ -58,6 +59,7 @@ The following parameters are optional:
5859
- :code:`rp_launch_description = 'Smoke test'` - launch description
5960
- :code:`rp_log_batch_size = 20` - size of batch log request
6061
- :code:`rp_ignore_errors = True` - Ignore Report Portal errors (exit otherwise)
62+
- :code:`rp_ignore_tags = 'xfail' 'usefixture'` - Ignore specified pytest markers
6163

6264

6365
Examples
@@ -127,6 +129,8 @@ In the following example tags 'linux' and 'win32' will be used:
127129
def test_one():
128130
pass
129131
132+
If you don't want to attach specific markers, list them in :code:`rp_ignore_tags` parameter
133+
130134

131135
Launching
132136
~~~~~~~~~

pytest_reportportal/plugin.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def pytest_sessionstart(session):
6363
uuid=session.config.getini("rp_uuid"),
6464
log_batch_size=int(session.config.getini("rp_log_batch_size")),
6565
ignore_errors=bool(session.config.getini("rp_ignore_errors")),
66+
ignored_tags=session.config.getini("rp_ignore_tags"),
6667
)
6768

6869
PyTestService.start_launch(
@@ -144,3 +145,8 @@ def pytest_addoption(parser):
144145
default=False,
145146
type="bool",
146147
help="Ignore Report Portal errors (exit otherwise)")
148+
149+
parser.addini(
150+
"rp_ignore_tags",
151+
type="args",
152+
help="Ignore specified pytest markers, i.e parametrize")

pytest_reportportal/service.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ class PyTestServiceClass(with_metaclass(Singleton, object)):
3131
def __init__(self):
3232
self.RP = None
3333
self.ignore_errors = True
34+
self.ignored_tags = []
3435
self._errors = queue.Queue()
3536

3637
def init_service(self, endpoint, project, uuid, log_batch_size,
37-
ignore_errors):
38+
ignore_errors, ignored_tags):
3839
self._errors = queue.Queue()
3940
if self.RP is None:
4041
self.ignore_errors = ignore_errors
42+
self.ignored_tags = ignored_tags
4143
logging.debug(
4244
msg="ReportPortal - Init service: "
4345
"endpoint={0}, project={1}, uuid={2}".
@@ -123,10 +125,12 @@ def _get_description(self, test_item):
123125

124126
def _get_tags(self, test_item):
125127
# try to extract names of @pytest.mark.* decorators used for test item
128+
# and exclude those which present in rp_ignore_tags parameter
126129
mark_plugin = test_item.config.pluginmanager.getplugin("mark")
127130
if mark_plugin:
128131
keywords = test_item.keywords
129-
return list(mark_plugin.MarkMapping(keywords)._mymarks)
132+
marks = mark_plugin.MarkMapping(keywords)._mymarks
133+
return [m for m in marks if m not in self.ignored_tags]
130134
else:
131135
return []
132136

0 commit comments

Comments
 (0)