# Copyright 2019 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.
import os import unittest
import mock import version
def _ReplaceArgs(args, *replacements):
new_args = args[:] for flag, val in replacements:
flag_index = args.index(flag)
new_args[flag_index + 1] = val return new_args
class _VersionTest(unittest.TestCase): """Unittests for the version module. """
@staticmethod def _RunBuildOutput(new_version_values={},
get_new_args=lambda old_args: old_args): """Parameterized helper method for running the main testable method in
version.py.
Keyword arguments:
new_version_values -- dict used to update _EXAMPLE_VERSION
get_new_args -- lambdafor updating _EXAMPLE_ANDROID_ARGS """
with mock.patch('version.FetchValuesFromFile') as \
fetch_values_from_file_mock:
def testFetchValuesFromFile(self): """It returns a dict in correct format - { : }, to verify
assumption of other tests that mock this function """
result = {}
version.FetchValuesFromFile(result, self._CHROME_VERSION_FILE)
for key, val in result.iteritems():
self.assertIsInstance(key, str)
self.assertIsInstance(val, str)
def testBuildOutputAndroid(self): """Assert it gives includes assignments of expected variables"""
output = self._RunBuildOutput(
get_new_args=lambda args: self._EXAMPLE_ANDROID_ARGS)
contents = output['contents']
def testBuildOutputAndroidChromeArchInput(self): """Assert it raises an exception when using an invalid architecture input"""
new_args = _ReplaceArgs(self._EXAMPLE_ANDROID_ARGS, ['-a', 'foobar']) with self.assertRaises(SystemExit) as cm:
self._RunBuildOutput(get_new_args=lambda args: new_args)
self.assertEqual(cm.exception.code, 2)
if __name__ == '__main__':
unittest.main()
Messung V0.5
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.