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

Unified Diff: build/android/devil/devil_env_test.py

Issue 1509493003: [Android] Fix environment variable handling in devil_env. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: windows-friendly environment initialization Created 5 years 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 | « build/android/devil/devil_env.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/devil/devil_env_test.py
diff --git a/build/android/devil/devil_env_test.py b/build/android/devil/devil_env_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..5bfef6687397c491b54396e6bdbc84f8b92da23e
--- /dev/null
+++ b/build/android/devil/devil_env_test.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# pylint: disable=protected-access
+
+import logging
+import sys
+import unittest
+
+from devil import devil_env
+
+_sys_path_before = list(sys.path)
+with devil_env.SysPath(devil_env.config.LocalPath('pymock')):
+ _sys_path_with_pymock = list(sys.path)
+ import mock # pylint: disable=import-error
+_sys_path_after = list(sys.path)
+
+class DevilEnvTest(unittest.TestCase):
+
+ def testSysPath(self):
+ self.assertEquals(_sys_path_before, _sys_path_after)
+ self.assertEquals(
+ _sys_path_before + [devil_env.config.LocalPath('pymock')],
+ _sys_path_with_pymock)
+
+ def testGetEnvironmentVariableConfig_configType(self):
+ with mock.patch('os.environ.get',
+ mock.Mock(side_effect=lambda _env_var: None)):
+ env_config = devil_env._GetEnvironmentVariableConfig()
+ self.assertEquals('BaseConfig', env_config.get('config_type'))
+
+ def testGetEnvironmentVariableConfig_noEnv(self):
+ with mock.patch('os.environ.get',
+ mock.Mock(side_effect=lambda _env_var: None)):
+ env_config = devil_env._GetEnvironmentVariableConfig()
+ self.assertEquals({}, env_config.get('dependencies'))
+
+ def testGetEnvironmentVariableConfig_adbPath(self):
+ def mock_environment(env_var):
+ return '/my/fake/adb/path' if env_var == 'ADB_PATH' else None
+
+ with mock.patch('os.environ.get',
+ mock.Mock(side_effect=mock_environment)):
+ env_config = devil_env._GetEnvironmentVariableConfig()
+ self.assertEquals(
+ {
+ 'adb': {
+ 'file_info': {
+ 'android_linux2': {
+ 'local_paths': ['/my/fake/adb/path'],
+ },
+ },
+ },
+ },
+ env_config.get('dependencies'))
+
+
+if __name__ == '__main__':
+ logging.getLogger().setLevel(logging.DEBUG)
+ unittest.main(verbosity=2)
« no previous file with comments | « build/android/devil/devil_env.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698