Skip to content

Commit

Permalink
Release 0.0.4 (reportportal#8)
Browse files Browse the repository at this point in the history
+ fixed problems with handling skipped tests status
+ added parameters to filter needless loggers
+ fixed problem with run logcapturing plugin
+ added travis configuration file
  • Loading branch information
skif-sarmat authored Oct 9, 2019
1 parent 416ede8 commit 52416dd
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 8 deletions.
27 changes: 27 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
stages:
- test
- name: deploy
if: tag IS present
language: python
python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
script:
- python setup.py -q install

jobs:
include:
- stage: deploy
python: '3.6'
script: skip
deploy:
stage: deploy
provider: pypi
on:
tags: true
distributions: sdist bdist_wheel
user: reportportal
password:
secure: jMfziY/3FrvJPvOIOf+txT+pOYlhhYjNS7rzMqLA6cAaTWW3h0kTIJKmBL6YtJv6q7nr42tgNy8H1eHkRk0eR3XwVZJ0J6H89sQkGRNo6cX9Dl+DJ+PgZIQ2jskTOYErB+J1B69WVx8RKStvmAIB1r5IdoBG8itPJTKrXLb+3QVH9oPTOaH9/JE50WPeU842xLQe04dCG3doIFvVGQYUlI/ZTLCpOiq1p8/K1CIzktMZlDlDfGho8V5uD+RuC8L/ZcJIDBzEP7NN9lzYLgfFSZiT/e48S8trYodON1xID/RWAOye2u0oFNoWeBpvp+JBcfQASSvoCwxOkuRp6R8g91g9E4RCUrYGwCKJqMqk2PjrlRKayfyHQjcu9yyjRtqix3eQV7fen9p2DesZtXTstGkD6GDhLUbQEjC+9ZqYVjVMKDdBtjQuWCrcJQoVSn1DmStK7oqo/am1KSO9OpgHqKGNwageD3fHGyCLxmhoiDRIMKbrDSJ0jmq8awBQ2WkyctLA3EjAy/NQd0Rf+BwjeGjQNa1OseLUKErIDiziPNQ8Po8pLf82qMqV25NtKEbAL60KxjlJO/Vh0UvMnh8OoK3yDrweTHyqDIfLJEymCHWsEPEJOxjYmXFhPPf7rnaTW36sncqr9Sh+TCPb2bGFL0uDQhCaUz9gBP/K1vUJdMM=
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,25 @@ If you like to override some of parameters above from command line, or from CI e

`--rp-launch-description` to change description of a launch

`--ignore-loggers` tto ignore external loggers and not send them in report portal. Specify which statements to filter. If the output is too verbose, use this option to filter out needless output.

Example:

```
filter=foo will capture statements issued ONLY to foo or foo.what.ever.sub but not foobar or other logger.
Specify multiple loggers with comma: filter=foo,bar,baz.
If any logger name is prefixed with a minus, eg filter=-foo, it will be excluded rather than included.
```

The following loggers are ignored
'nose'
'reportportal_client.service_async'
'reportportal_client.service' ,
'nose_reportportal.plugin'
'nose_reportportal.service'
'urllib3.connectionpool'
by default.

# Launching

To run test with Report Portal you must provide '--with-reportportal' flag:
Expand All @@ -78,6 +97,11 @@ Apache License Version 2.0: http://www.apache.org/licenses/LICENSE-2.0

# Changes

## Changes in version 0.0.4

* fixed bug with handling of skip status of a test
* added argument to ignore loggers

## Changes in version 0.0.3

* a safe logs-sender was added on a stop test phase
Expand Down
54 changes: 47 additions & 7 deletions nose_reportportal/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,34 @@
import traceback
from nose.plugins.base import Plugin
from nose.plugins.logcapture import MyMemoryHandler
from nose.plugins.skip import SkipTest
from nose.plugins.deprecated import DeprecatedTest
from .service import NoseServiceClass

from nose.pyversion import exc_to_unicode, force_unicode
from nose.util import safe_str
from nose.util import safe_str, isclass


log = logging.getLogger(__name__)
# Disabled because we've already had a overloaded capturing of the logs
LogCapture.enabled = False


class RPNoseLogHandler(MyMemoryHandler):
def __init__(self):
def __init__(self, extended_filters=None):
logformat = '%(name)s: %(levelname)s: %(message)s'
logdatefmt = None
filters = ['-nose', '-reportportal_client.service_async',
filters = ['-nose', '-reportportal_client.service_async',
'-reportportal_client.service', '-nose_reportportal.plugin',
'-nose_reportportal.service']
if extended_filters:
filters.extend(extended_filters)
super(RPNoseLogHandler, self).__init__(logformat, logdatefmt, filters)


class ReportPortalPlugin(Plugin):
can_configure = True
score = 200
score = SkipTest.score + 1
status = {}
enableOpt = None
name = "reportportal"
Expand All @@ -53,6 +61,7 @@ def __init__(self):
super(ReportPortalPlugin, self).__init__()
self.stdout = []
self._buf = None
self.filters = None

def options(self, parser, env):
"""
Expand Down Expand Up @@ -83,6 +92,13 @@ def options(self, parser, env):
dest='rp_launch_description',
help='description of a launch')

parser.add_option('--ignore-loggers',
action='store',
default=[],
dest='ignore_loggers',
help='logger filter')


def configure(self, options, conf):
"""
Configure plugin.
Expand Down Expand Up @@ -120,6 +136,10 @@ def configure(self, options, conf):
slaunch = "(component tests)"

self.rp_mode = options.rp_mode if options.rp_mode in ("DEFAULT", "DEBUG") else "DEFAULT"

if options.ignore_loggers and isinstance(options.ignore_loggers, basestring):
self.filters = [x.strip() for x in options.ignore_loggers.split(",")]

self.clear = True
if "base" in config.sections():
self.rp_uuid = config.get("base", "rp_uuid")
Expand Down Expand Up @@ -173,7 +193,7 @@ def begin(self):
description=self.rp_launch_description,
mode=self.rp_mode)

self.handler = RPNoseLogHandler()
self.handler = RPNoseLogHandler(self.filters if self.filters else None)
self.setupLoghandler()

def _restore_stdout(self):
Expand Down Expand Up @@ -245,18 +265,38 @@ def _addError(self, test, err):
test.errors.append(value)
test.errors.append(str(etype.__name__) + ":\n" + "".join(traceback.format_tb(tb)))

def _filterErrorForSkip(self, err):
if isinstance(err, tuple) and isclass(err[0]):
if issubclass(err[0], SkipTest):
return True
return False

def _filterErrorForDepricated(self, err):
if isinstance(err, tuple) and isclass(err[0]):
if issubclass(err[0], DeprecatedTest):
return True
return False

def addError(self, test, err):
"""Called when a test raises an uncaught exception. DO NOT return a
value unless you want to stop other plugins from seeing that the
test has raised an error.
Calling addSkip() and addDeprecated() from base plugin was
deprecated and there is need to handle skipped and deprecated tests inside addError().
:param test: the test case
:type test: :class:`nose.case.Test`
:param err: sys.exc_info() tuple
:type err: 3-tuple
"""
test.status = "error"
self._addError(test, err)

if self._filterErrorForSkip(err):
self.addSkip(test)
elif self._filterErrorForDepricated(err):
self.addDeprecated(test)
else:
test.status = "error"
self._addError(test, err)

def addFailure(self, test, err):
"""Called when a test fails. DO NOT return a value unless you
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def read_file(fname):
return f.read()


version = '0.0.3'
version = '0.0.4'
tar_url = 'https://github.com/reportportal/agent-python-nosetests'


Expand Down

0 comments on commit 52416dd

Please sign in to comment.