Tests for lldb are written as python scripts which take advantage of the script bridging provided by LLDB.framework to interact with lldb core. A specific naming pattern is followed by the .py script to be recognized as a module which implements a test scenario, namely, Test*.py. To specify the directories where "Test*.py" python test scripts are located, you need to pass in a list of directory names. By default, the current working directory is searched if nothing is specified on the command line. An example: [14:10:20] johnny:/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v example test_choice (TestSequenceFunctions.TestSequenceFunctions) ... ok test_sample (TestSequenceFunctions.TestSequenceFunctions) ... ok test_shuffle (TestSequenceFunctions.TestSequenceFunctions) ... ok ---------------------------------------------------------------------- Ran 3 tests in 0.000s OK llvm-svn: 106890
35 lines
867 B
Python
35 lines
867 B
Python
"""An example unittest copied from python tutorial."""
|
|
|
|
import random
|
|
import unittest
|
|
import traceback
|
|
|
|
class TestSequenceFunctions(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
#traceback.print_stack()
|
|
self.seq = range(10)
|
|
|
|
def tearDown(self):
|
|
#traceback.print_stack()
|
|
pass
|
|
|
|
def test_shuffle(self):
|
|
# make sure the shuffled sequence does not lose any elements
|
|
random.shuffle(self.seq)
|
|
self.seq.sort()
|
|
self.assertEqual(self.seq, range(10))
|
|
|
|
def test_choice(self):
|
|
element = random.choice(self.seq)
|
|
self.assertTrue(element in self.seq)
|
|
|
|
def test_sample(self):
|
|
self.assertRaises(ValueError, random.sample, self.seq, 20)
|
|
for element in random.sample(self.seq, 5):
|
|
self.assertTrue(element in self.seq)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|