Skip to content
Snippets Groups Projects
Commit 05f0189a authored by Tri Vo's avatar Tri Vo
Browse files

Add internal/lib/driver_test_lib.py to fix unit tests.

Add a script to run all unit tests.
Test: tools/acloud/run_tests.sh
parent fed6a6f6
No related branches found
No related tags found
No related merge requests found
*.pyc
*.*~
......@@ -11,4 +11,9 @@ Devices on Google Compute Engine) instantiated by using the Android source code
`$ pip install acloud.zip`
#3. Execution:
`$ acloud <flags>
To run all unit tests:
`$ tools\acloud\run_tests.sh`
#!/usr/bin/env python
#
# Copyright 2017 - The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Driver test library."""
import mock
import unittest
class BaseDriverTest(unittest.TestCase):
"""Base class for driver tests."""
def setUp(self):
"""Set up test."""
self._patchers = []
def tearDown(self):
"""Tear down test."""
for patcher in reversed(self._patchers):
patcher.stop()
def Patch(self, *args, **kwargs):
"""A wrapper for mock.patch.object.
This wrapper starts a patcher and store it in self._patchers,
so that we can later stop them in tearDown.
Args:
*args: Arguments to pass to mock.patch.
**kwargs: Keyword arguments to pass to mock.patch.
Returns:
Mock object
"""
patcher = mock.patch.object(*args, **kwargs)
self._patchers.append(patcher)
return patcher.start()
......@@ -24,7 +24,7 @@ import mock
import unittest
from acloud.internal.lib import auth
from acloud.internal.lib import andorid_build_client
from acloud.internal.lib import android_build_client
from acloud.internal.lib import android_compute_client
from acloud.internal.lib import driver_test_lib
from acloud.internal.lib import gstorage_client
......
#!/bin/bash
if [ -z "$ANDROID_BUILD_TOP" ]; then
echo "Missing ANDROID_BUILD_TOP env variable. Run 'lunch' first."
exit 1
fi
# Runs all unit tests under tools/acloud.
tests=$(find . -type f | grep test\.py)
for t in $tests; do
PYTHONPATH=$ANDROID_BUILD_TOP/tools python $t;
done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment