Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Unified Diff: tools/telemetry/telemetry/core/util_unittest.py

Issue 321773002: [PowerProfiler] Make sure correct version of pySerial is imported with monsoon profiler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated unit test to remove version number hardcoding! Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/telemetry/telemetry/core/util.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/core/util_unittest.py
diff --git a/tools/telemetry/telemetry/core/util_unittest.py b/tools/telemetry/telemetry/core/util_unittest.py
index 05df311add92e3cd88288185694dbfc19e946b2a..2c5c7736f42f660bdeb01d85cfb9c9e3fd4f9092 100644
--- a/tools/telemetry/telemetry/core/util_unittest.py
+++ b/tools/telemetry/telemetry/core/util_unittest.py
@@ -4,6 +4,7 @@
import os
import unittest
import shutil
+import sys
import tempfile
from telemetry.core import util
@@ -62,3 +63,35 @@ class TestGetSequentialFileName(unittest.TestCase):
def tearDown(self):
shutil.rmtree(self.test_directory)
+
+class PySerialVersionTest(unittest.TestCase):
tonyg 2014/06/11 15:44:00 This is getting convoluted. Stepping back, what yo
+ def testPySerialVersion(self):
+ third_party_pyserial_path = os.path.abspath(\
+ os.path.join(util.GetTelemetryDir(), 'third_party', 'pyserial'))
+
+ # Make an explicit call to sys.path.insert(0,...) to make sure the serial
+ # library is indeed from third_party/pyserial
+ sys.path.insert(0, third_party_pyserial_path)
+ import serial
+ third_party_pyserial_version = serial.VERSION
+
+ # Remove all traces of third_party_pyserial_path from the sys.path
+ while sys.path.count(third_party_pyserial_path):
+ sys.path.remove(third_party_pyserial_path)
+
+ try:
+ # Try to load serial from the system library if its available
+ reload(serial)
+ system_library_version = serial.VERSION
+
+ # The version number may or may not match but we can safely ignore it
+ self.assertEqual(system_library_version, third_party_pyserial_version)
+ except AssertionError:
+ # Ignoring both cases
+ # 1. Serial not being part of any system library
+ # 2. Version number mismatch
+ pass
+
+ util.AddDirToPythonPath(third_party_pyserial_path)
+ reload(serial)
+ self.assertEqual(serial.VERSION, third_party_pyserial_version)
« no previous file with comments | « tools/telemetry/telemetry/core/util.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698