-
Notifications
You must be signed in to change notification settings - Fork 65
Adding integration test for json.result formatting #325
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
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -4,11 +4,15 @@ | |
| import mock | ||
| from optparse import OptionParser | ||
| import time | ||
| import os | ||
| import subprocess | ||
| import sys | ||
| import tempfile | ||
|
|
||
| import six | ||
|
|
||
| from testify import compat | ||
| from testify import assert_equal, TestCase | ||
| from testify import assert_equal, assert_in, TestCase | ||
| from testify.test_result import TestResult | ||
| from testify.plugins.test_case_time_log import add_command_line_options, TestCaseJSONReporter | ||
|
|
||
|
|
@@ -73,3 +77,22 @@ def test_json_reporter_reports(self): | |
| json.loads(self.reporter.log_file.getvalue()), | ||
| json.loads(output_str), | ||
| ) | ||
|
|
||
| def test_test_case_results_reports(self): | ||
| tempdir = tempfile.mkdtemp() | ||
| temp_json_file = os.path.join(tempdir, 'tmp.json') | ||
|
Contributor
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. this leaks the tempdir and tempfile, you should use a context manager to clean that up You can peek at |
||
| subprocess.check_call(( | ||
| sys.executable, | ||
| '-m', | ||
| 'testify.test_program', | ||
| '--test-case-results', | ||
| temp_json_file, | ||
| 'test/test_suite_subdir/define_testcase.py' | ||
| )) | ||
| with open(temp_json_file, 'r') as f: | ||
|
Contributor
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.
|
||
| result = f.readlines()[0] | ||
|
Contributor
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'd just do |
||
| contents = json.loads(result) | ||
| assert_in('start_time', contents) | ||
| assert_in('end_time', contents) | ||
| assert_in('success', contents) | ||
| assert_in('method', contents) | ||
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'd delete the unit test since this entirely covers the behaviour without fragile mocking