Skip to content

Conversation

@lebovski
Copy link

  • Rewritten listener class for support pytest fixtures
  • Improved RPLogger class for correct write test info
  • Make code more pythonic
  • The listener code is in a separate file
  • The logger code is in a separate file
  • Used html library instead of cgi

@krasoffski
Copy link
Contributor

@lebovski, many thanks!
I will take a look at you PR.

Copy link
Contributor

@krasoffski krasoffski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a brief review for obvious changes. I'll continue after work.

loglevel=self._loglevel_map[level],
attachment=record.__dict__.get("attachment", None),
)
from .rp_logging import RPLogger, RPLogHandler
Copy link
Contributor

@krasoffski krasoffski Nov 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid warn about not used imports, please add

__all__ = [RPLogger, RPLogHandler]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

group = parser.getgroup("reporting")
group.addoption(
"--rp-launch",
'--rp-launch',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason to change quotes here and keep double quotes in other places?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

logging.debug(
msg="ReportPortal - Init service: "
"endpoint={0}, project={1}, uuid={2}".
msg='ReportPortal - Init service: endpoint={0}, project={1}, uuid={2}'.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please limit line length up to 79 chars (inclusive).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -0,0 +1,45 @@
import html
Copy link
Contributor

@krasoffski krasoffski Nov 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does html module exist in the Python2.7? Also this module is not a dependency of pytest. Than is why solution with cgi was chosen.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Fixed.

def __init__(self, name, level=0):
super(RPLogger, self).__init__(name, level=level)

def _log(self, level, msg, args, exc_info=None, extra=None, stack_info=False, attachment=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Length up to 79 chars.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

if exc_info and not isinstance(exc_info, tuple):
exc_info = sys.exc_info()

record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra, sinfo)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

79 chars here, please check other places for this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -0,0 +1,2 @@
# Created by .ignore support plugin (hsz.mobi)
Copy link
Contributor

@krasoffski krasoffski Nov 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, it is a good practice to split a list of changes using commits. This simplifies review and keeps attention on important topics.
E.g.
1 commit: update quotes
2 commit: add support of fixtures
3 commit: something else

During a review you will see squashed changes, but if you want to review a particular topic you can do this with approach above but with big commit like yours it is not possible (in case of renamed files it is quite difficult)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I completely agree. Thanks for the advice.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will follow this advice in next time.

super(RPLogHandler, self).__init__(level)

# Map loglevel codes from `logging` module to ReportPortal text names:
self._loglevel_map = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason to move _loglevel_map to __init__?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIxed.

Copy link
Contributor

@krasoffski krasoffski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some comments after review.

tar_url = "https://github.com/reportportal/agent-python-pytest/tarball/1.0.0"
version = '1.1.0'
tar_url = 'https://github.com/reportportal/agent-python-pytest/tarball/1.0.0'

Copy link
Contributor

@krasoffski krasoffski Nov 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is 1.0.1 because there is no major features, only defect fixes.
Also, do not forget to update tar_url path for tarball.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

log_batch_size=int(session.config.getini("rp_log_batch_size")),
ignore_errors=bool(session.config.getini("rp_ignore_errors")),
ignored_tags=session.config.getini("rp_ignore_tags"),
project=session.config.getini('rp_project'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the main reason to use ' single quote instead of " double quote?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are using single and double quotes in code, for uniformity of the written code it is better to use only single or double, i prefer single.

@krasoffski krasoffski merged commit b64f195 into reportportal:master Nov 22, 2017
@krasoffski
Copy link
Contributor

Merged, but would be great to test the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants