qubes/tests: Move unit tests inside qubes/, add runner
This commit is contained in:
parent
c414ab6df0
commit
a82bf7cc54
10
qubes/tests/__init__.py
Normal file
10
qubes/tests/__init__.py
Normal file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/python -O
|
||||
|
||||
import unittest
|
||||
|
||||
class QubesTestCase(unittest.TestCase):
|
||||
def __str__(self):
|
||||
return '{}/{}/{}'.format(
|
||||
'.'.join(self.__class__.__module__.split('.')[2:]),
|
||||
self.__class__.__name__,
|
||||
self._testMethodName)
|
@ -3,10 +3,11 @@
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(0, '..')
|
||||
import qubes.events
|
||||
|
||||
class TC_Emitter(unittest.TestCase):
|
||||
import qubes.tests
|
||||
|
||||
class TC_00_Emitter(qubes.tests.QubesTestCase):
|
||||
def test_000_add_handler(self):
|
||||
# need something mutable
|
||||
testevent_fired = [False]
|
@ -5,12 +5,13 @@ import unittest
|
||||
|
||||
import lxml.etree
|
||||
|
||||
sys.path.insert(0, '../')
|
||||
import qubes
|
||||
import qubes.events
|
||||
import qubes.vm
|
||||
|
||||
class TC_10_Label(unittest.TestCase):
|
||||
import qubes.tests
|
||||
|
||||
class TC_10_Label(qubes.tests.QubesTestCase):
|
||||
def test_000_constructor(self):
|
||||
label = qubes.Label(1, '#cc0000', 'red')
|
||||
|
||||
@ -45,7 +46,7 @@ class TestHolder(qubes.PropertyHolder):
|
||||
testprop3 = qubes.property('testprop3', order=2, default='testdefault')
|
||||
testprop4 = qubes.property('testprop4', order=3)
|
||||
|
||||
class TC_00_PropertyHolder(unittest.TestCase):
|
||||
class TC_00_PropertyHolder(qubes.tests.QubesTestCase):
|
||||
def assertXMLEqual(self, xml1, xml2):
|
||||
self.assertEqual(xml1.tag, xml2.tag)
|
||||
self.assertEqual(xml1.text, xml2.text)
|
||||
@ -103,7 +104,7 @@ class TestVM(qubes.vm.BaseVM):
|
||||
class TestApp(qubes.events.Emitter):
|
||||
pass
|
||||
|
||||
class TC_11_VMCollection(unittest.TestCase):
|
||||
class TC_11_VMCollection(qubes.tests.QubesTestCase):
|
||||
def setUp(self):
|
||||
# XXX passing None may be wrong in the future
|
||||
self.vms = qubes.VMCollection(TestApp())
|
||||
@ -203,5 +204,5 @@ class TC_11_VMCollection(unittest.TestCase):
|
||||
# pass
|
||||
|
||||
|
||||
class TC_20_Qubes(unittest.TestCase):
|
||||
class TC_20_Qubes(qubes.tests.QubesTestCase):
|
||||
pass
|
26
qubes/tests/run.py
Executable file
26
qubes/tests/run.py
Executable file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/python -O
|
||||
|
||||
import importlib
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
test_order = [
|
||||
'qubes.tests.events',
|
||||
'qubes.tests.vm.init',
|
||||
'qubes.tests.vm.qubesvm',
|
||||
'qubes.tests.init'
|
||||
]
|
||||
|
||||
sys.path.insert(0, '../../')
|
||||
|
||||
def main():
|
||||
suite = unittest.TestSuite()
|
||||
loader = unittest.TestLoader()
|
||||
for modname in test_order:
|
||||
module = importlib.import_module(modname)
|
||||
suite.addTests(loader.loadTestsFromModule(module))
|
||||
|
||||
unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(suite)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
0
qubes/tests/vm/__init__.py
Normal file
0
qubes/tests/vm/__init__.py
Normal file
@ -5,11 +5,12 @@ import unittest
|
||||
|
||||
import lxml.etree
|
||||
|
||||
sys.path.insert(0, '../')
|
||||
import qubes
|
||||
import qubes.events
|
||||
import qubes.vm
|
||||
|
||||
import qubes.tests
|
||||
|
||||
|
||||
class TestEmitter(qubes.events.Emitter):
|
||||
def __init__(self):
|
||||
@ -38,7 +39,7 @@ class TestEmitter(qubes.events.Emitter):
|
||||
if self.device_pre_detached_fired:
|
||||
self.device_detached_fired = True
|
||||
|
||||
class TC_00_DeviceCollection(unittest.TestCase):
|
||||
class TC_00_DeviceCollection(qubes.tests.QubesTestCase):
|
||||
def setUp(self):
|
||||
self.emitter = TestEmitter()
|
||||
self.collection = qubes.vm.DeviceCollection(self.emitter, 'testclass')
|
||||
@ -79,7 +80,7 @@ class TC_00_DeviceCollection(unittest.TestCase):
|
||||
self.collection.detach('testdev')
|
||||
|
||||
|
||||
class TC_01_DeviceManager(unittest.TestCase):
|
||||
class TC_01_DeviceManager(qubes.tests.QubesTestCase):
|
||||
def setUp(self):
|
||||
self.emitter = TestEmitter()
|
||||
self.manager = qubes.vm.DeviceManager(self.emitter)
|
||||
@ -99,7 +100,7 @@ class TestVM(qubes.vm.BaseVM):
|
||||
testlabel = qubes.property('testlabel')
|
||||
defaultprop = qubes.property('defaultprop', default='defaultvalue')
|
||||
|
||||
class TC_10_BaseVM(unittest.TestCase):
|
||||
class TC_10_BaseVM(qubes.tests.QubesTestCase):
|
||||
def setUp(self):
|
||||
self.xml = lxml.etree.XML('''
|
||||
<qubes version="3"> <!-- xmlns="https://qubes-os.org/QubesXML/1" -->
|
@ -2,11 +2,12 @@
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
sys.path.insert(0, '../../')
|
||||
|
||||
import qubes
|
||||
import qubes.vm.qubesvm
|
||||
|
||||
import qubes.tests
|
||||
|
||||
|
||||
class TestProp(object):
|
||||
__name__ = 'testprop'
|
||||
@ -21,7 +22,7 @@ class TestVM(object):
|
||||
return self.running
|
||||
|
||||
|
||||
class TC_00_setters(unittest.TestCase):
|
||||
class TC_00_setters(qubes.tests.QubesTestCase):
|
||||
def setUp(self):
|
||||
self.vm = TestVM()
|
||||
self.prop = TestProp()
|
||||
@ -73,7 +74,7 @@ class TC_00_setters(unittest.TestCase):
|
||||
pass
|
||||
|
||||
|
||||
class TC_90_QubesVM(unittest.TestCase):
|
||||
class TC_90_QubesVM(qubes.tests.QubesTestCase):
|
||||
@unittest.skip('test not implemented')
|
||||
def test_000_init(self):
|
||||
pass
|
Loading…
Reference in New Issue
Block a user