blob: 87e1824774444899bc25ffe9223f9968042865d7 [file] [log] [blame]
mbligh374f3412009-05-13 21:29:45 +00001#!/usr/bin/python
2
3"""Tests for autoserv_parser."""
4
5import sys
6import unittest
7
8import common
9from autotest_lib.server import autoserv_parser
10
11
12class autoserv_parser_test(unittest.TestCase):
13 def setUp(self):
14 self.orig_sys_argv = sys.argv
15
16 def tearDown(self):
17 sys.argv = self.orig_sys_argv
18
19 def _get_parser(self):
20 # We resort to this vile hack because autoserv_parser is bad
21 # enough to instantiate itself and replace its own class definition
22 # with its instance at module import time. Disgusting.
23 return autoserv_parser.autoserv_parser.__class__()
24
25 def test_control_file_args(self):
26 sys.argv = [None, '--args', '-y -z foo --hello', 'controlfile']
27 parser = self._get_parser()
28 parser.parse_args()
29 self.assertEqual(['controlfile', '-y', '-z', 'foo', '--hello'],
30 parser.args)
31
32
33if __name__ == '__main__':
34 unittest.main()