-
Notifications
You must be signed in to change notification settings - Fork 104
RPPT-001 | Rewrite listener, fix rp_logger. Make code more pythonic. #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
lebovski
commented
Nov 21, 2017
- 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
|
@lebovski, many thanks! |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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]
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
pytest_reportportal/service.py
Outdated
| logging.debug( | ||
| msg="ReportPortal - Init service: " | ||
| "endpoint={0}, project={1}, uuid={2}". | ||
| msg='ReportPortal - Init service: endpoint={0}, project={1}, uuid={2}'. |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
pytest_reportportal/listener.py
Outdated
| @@ -0,0 +1,45 @@ | |||
| import html | |||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. Fixed.
pytest_reportportal/rp_logging.py
Outdated
| 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): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
pytest_reportportal/rp_logging.py
Outdated
| 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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) | |||
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
pytest_reportportal/rp_logging.py
Outdated
| super(RPLogHandler, self).__init__(level) | ||
|
|
||
| # Map loglevel codes from `logging` module to ReportPortal text names: | ||
| self._loglevel_map = { |
There was a problem hiding this comment.
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__?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FIxed.
There was a problem hiding this 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' | ||
|
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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'), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
|
Merged, but would be great to test the latest version. |