-
-
Notifications
You must be signed in to change notification settings - Fork 435
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
Enable generation of html report of integration tests, and upload to dokuwiki. #570
Conversation
- This method is automatically picked up and called by pytest during initialization. - To generate an html report, --html flag was used, filepath was provided through command line but this flag isn't necessary anymore as filepath is added in pytest_configure(). - Naming is done in accordance to tardis.__githash__
- This method is included in top level conftest and called after the tests are executed. It establishes a dokuwiki connection and uploads test report to dokuwiki. Naming is done as per githash. - Local file containing html test report is finally deleted.
The resources referred were: Test execution looks like this: Here is the report for fafa9e5, which is specified in the screenshot: |
def pytest_unconfigure(config): | ||
# Html report created by pytest-html plugin is read here, uploaded to | ||
# dokuwiki and finally deleted. | ||
try: |
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 should do a try and except statement at the beginning with then just having dokuwiki_available boolean variable.
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'll do it that way then.
- Done.
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.
the try-except block should only contain things that fail. Move this block up to the import statements and only use if here.
3d81297
to
846952d
Compare
# Upload report on dokuwiki. Temporary link due to prototyping purposes. | ||
doku_conn.pages.append("reports:{0}".format(githash[:7]), report_content) | ||
except gaierror, dokuwiki.DokuWikiError: | ||
pass |
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.
again - stick the things that generate the error in the try except block and nothing else.
|
||
try: | ||
import dokuwiki | ||
dokuwiki_available = True |
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.
same goes here - the things that raise the error need to be in the try, but nothing else.
- Remove all print statements from pytest_unconfigure (they might be included in debug log afterwards.) - Reorder import statements and add block comments.
"Test executed on commit " | ||
"[[https://www.github.com/tardis-sn/tardis/commit/{0}|{0}]]\n\n" | ||
"{1}".format(githash, report_content) | ||
) |
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.
@wkerzendorf These four lines are good to be here or in else
block ? I spoke to myself: try to make a connection, except these two errors, else upload the report we have. Hence, I kept the report ready beforehand (compromising the time of execution of these lines if connection isn't at all made.)
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.
@karandesai-96 it's not about execution time it's about making the code easy to understand. What really happens when the if is True, what happens when the if is False. I think its fine the way it is for now.
This PR introduces a set of pytest functions which would be complaint with pytest-html. These fixtures introduce a layer of customization over default html report provided by plugin.
pytest_configure
method, before test execution. It assigns a tempfile path toconfig.option.filepath
for writing html report.pytest_unconfigure
, serves as a global teardown. It uploads the test report to dokuwiki.--slow-tests-data
has been renamed to--integration-tests
and it accepts a path to YAML configuration for running slow tests. All other related fixtures have been modified. For now the schema of configuration file is:This configuration file is parsed as a dict in a fixture created in conftest.py.
The checklist here maintains the status of work on this PR:
--html
may no longer be required.