-
-
Notifications
You must be signed in to change notification settings - Fork 409
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
Subclass pytest-html's HTMLReport to DokuReport class for report generation and upload. #583
Changes from 1 commit
116aeb5
4e4fadc
dd0666e
5a56b87
21c2316
a392364
7bc2642
6ec110a
3974851
889c343
1868918
7b6135d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,10 +32,12 @@ def __init__(self, dokuwiki_details): | |
password=dokuwiki_details["password"]) | ||
except gaierror, dokuwiki.DokuWikiError: | ||
self.doku_conn = None | ||
print "Dokuwiki connection could not be established!" | ||
else: | ||
self.doku_conn = None | ||
|
||
# This variable will be set True when report gets uploaded on Dokuwiki. | ||
self.is_report_uploaded = False | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't use a variable but check in sessionfinish that the page is indeed accessible. |
||
|
||
def _generate_report(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I imagined There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay we'll do it this way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For now you can copy/paste the code from pytest-html and note somewhere that it's copy/paste |
||
suite_stop_time = time.time() | ||
suite_time_delta = suite_stop_time - self.suite_start_time | ||
|
@@ -110,12 +112,24 @@ def _save_report(self): | |
self.logfile.seek(0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add |
||
|
||
if self.doku_conn is not None: | ||
self.doku_conn.pages.set("reports:{0}".format( | ||
tardis.__githash__[:7]), self.logfile.read()) | ||
print "Uploaded report on Dokuwiki." | ||
try: | ||
self.doku_conn.pages.set("reports:{0}".format( | ||
tardis.__githash__[:7]), self.logfile.read()) | ||
except gaierror: | ||
self.is_report_uploaded = False | ||
else: | ||
self.is_report_uploaded = True | ||
|
||
self.logfile.close() | ||
|
||
def pytest_sessionfinish(self, session): | ||
self._generate_report() | ||
self._save_report() | ||
|
||
def pytest_terminal_summary(self, terminalreporter): | ||
if self.is_report_uploaded: | ||
terminalreporter.write_sep( | ||
"-", "Successfully uploaded report to Dokuwiki") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be great if you could add the URL, too. |
||
else: | ||
terminalreporter.write_sep( | ||
"-", "Connection not established, upload failed.") |
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.
remove the if/else and add an except for the case dokuwiki=none