aboutsummaryrefslogtreecommitdiff
path: root/crosperf/crosperf_unittest.py
diff options
context:
space:
mode:
authorAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-02-05 21:17:18 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-02-05 21:17:18 +0000
commit3c0fcaf157c060979b09c0d8e7a982ff5d1acdab (patch)
treef592e7ccc058bdd6c0beda99a104df4f73c5e1d3 /crosperf/crosperf_unittest.py
parenteef05f06e8d4f7d4b4df22a398fba3af34fd27a6 (diff)
parentcfb8763e2bfd3fbba55c880a2858b8c73a1cd3ad (diff)
downloadtoolchain-utils-3c0fcaf157c060979b09c0d8e7a982ff5d1acdab.tar.gz
Merging 8 commit(s) from Chromium's toolchain-utils am: 928fba9d74 am: cfb8763e2b
Change-Id: Id8b0ba2600fa220974d0f116efaa990580387d18
Diffstat (limited to 'crosperf/crosperf_unittest.py')
-rwxr-xr-xcrosperf/crosperf_unittest.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/crosperf/crosperf_unittest.py b/crosperf/crosperf_unittest.py
index f7ffa1b7..ffd964a2 100755
--- a/crosperf/crosperf_unittest.py
+++ b/crosperf/crosperf_unittest.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
@@ -12,11 +12,9 @@ from __future__ import print_function
import argparse
import io
-import os
import tempfile
import unittest
-
-import mock
+import unittest.mock as mock
import crosperf
import settings_factory
@@ -46,14 +44,14 @@ class CrosperfTest(unittest.TestCase):
"""Crosperf test class."""
def setUp(self):
- input_file = io.BytesIO(EXPERIMENT_FILE_1)
+ input_file = io.StringIO(EXPERIMENT_FILE_1)
self.exp_file = experiment_file.ExperimentFile(input_file)
def testDryRun(self):
- filehandle, filename = tempfile.mkstemp()
- os.write(filehandle, EXPERIMENT_FILE_1)
- crosperf.Main(['', filename, '--dry_run'])
- os.remove(filename)
+ with tempfile.NamedTemporaryFile('w', encoding='utf-8') as f:
+ f.write(EXPERIMENT_FILE_1)
+ f.flush()
+ crosperf.Main(['', f.name, '--dry_run'])
def testConvertOptionsToSettings(self):
parser = argparse.ArgumentParser()