~larry-e-works/uci-engine/write-exitcode-to-file

« back to all changes in this revision

Viewing changes to test_runner/tstrun/run_test.py

  • Committer: Larry Works
  • Date: 2015-01-16 19:10:51 UTC
  • Revision ID: larry.works@canonical.com-20150116191051-9bhx2rsrn3c8y8kz
Incorporated Pauls recommendation to user context manager instead of the explicit open/close.

Show diffs side-by-side

added added

removed removed

Lines of Context:
171
171
    subunit_path = '{}.subunit'.format(package)
172
172
    output = open(subunit_path, 'wb')
173
173
    ec_path = os.path.join('results', 'exit_code')
174
 
    exitcode = open(ec_path, 'wb')
175
174
    result = subunit.TestProtocolClient(output)
176
175
    result.startTestRun()
177
176
    pkg_version = None
191
190
        proc, _, _ = run(*cmd, check_rc=False)
192
191
        rc = proc.returncode
193
192
        ec = str(rc)
194
 
        exitcode.write(ec)
 
193
        with open(ec_path, 'w') as exitcode:
 
194
            exitcode.write(ec)
195
195
        pkg_version = package_version('results')
196
196
        deps_versions = aggregate_versions('results')
197
197
        for name, status in parse_summary(summary_path):
199
199
    finally:
200
200
        result.stopTestRun()
201
201
        output.close()
202
 
        exitcode.close()
203
202
    return rc, pkg_version, deps_versions