diff options
Diffstat (limited to 'lldb/test/example/TestSequenceFunctions.py')
-rw-r--r-- | lldb/test/example/TestSequenceFunctions.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lldb/test/example/TestSequenceFunctions.py b/lldb/test/example/TestSequenceFunctions.py new file mode 100644 index 00000000000..29ebfe6cefe --- /dev/null +++ b/lldb/test/example/TestSequenceFunctions.py @@ -0,0 +1,34 @@ +"""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() |