Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 import types
6 import unittest
8 import mozlog
10 from mozdevice import devicemanager
11 from mozdevice import devicemanagerSUT
13 ip = ''
14 port = 0
15 heartbeat_port = 0
16 log_level = mozlog.ERROR
18 class DeviceManagerTestCase(unittest.TestCase):
19 """DeviceManager tests should subclass this.
20 """
22 """Set to False in your derived class if this test
23 should not be run on the Python agent.
24 """
25 runs_on_test_device = True
27 def _setUp(self):
28 """ Override this if you want set-up code in your test."""
29 return
31 def setUp(self):
32 self.dm = devicemanagerSUT.DeviceManagerSUT(host=ip, port=port,
33 logLevel=log_level)
34 self.dmerror = devicemanager.DMError
35 self._setUp()
38 class DeviceManagerTestLoader(unittest.TestLoader):
40 def __init__(self, isTestDevice=False):
41 self.isTestDevice = isTestDevice
43 def loadTestsFromModuleName(self, module_name):
44 """Loads tests from modules unless the SUT is a test device and
45 the test case has runs_on_test_device set to False
46 """
47 tests = []
48 module = __import__(module_name)
49 for name in dir(module):
50 obj = getattr(module, name)
51 if (isinstance(obj, (type, types.ClassType)) and
52 issubclass(obj, unittest.TestCase)) and \
53 (not self.isTestDevice or obj.runs_on_test_device):
54 tests.append(self.loadTestsFromTestCase(obj))
55 return self.suiteClass(tests)