Example #1
0
 def setUp(self):
     self.menu = SelectorMenu()
     self.menu.item_markup = (r'\[', r'\]')
     self.menu.item_class = '0-9'
     self.menu.separator = ' '
     self.menu.label_class = 'a-zA-Z0-9'
     self.menu.prompt = None
Example #2
0
 def setUp(self):
     self.menu = SelectorMenu()
     self.menu.item_markup = (r'\[', r'\]')
     self.menu.item_class = '0-9'
     self.menu.separator = ' '
     self.menu.label_class = 'a-zA-Z0-9'
     self.menu.prompt = None
Example #3
0
class TestSelectorMenu(StdoutTestCase):
    def setUp(self):
        super(TestSelectorMenu, self).setUp()
        self.menu = SelectorMenu()
        self.menu.item_markup = (r'\[', r'\]')
        self.menu.item_class = '0-9'
        self.menu.separator = ' '
        self.menu.label_class = 'a-zA-Z0-9'
        self.menu.prompt = None

    def test_menu_parser(self):
        pattern = "%s([%s]+)%s%s([%s]*)" % (
            re.escape(self.menu.item_markup[0]), self.menu.item_class,
            re.escape(self.menu.item_markup[1]), self.menu.separator,
            self.menu.label_class)
        serial_input = """
    [1] debian
    [2] tester
    [3] Shell
    [4] Boot Manager
    [5] Reboot
    [6] Shutdown
    Start:
            """
        selection = self.menu.select(serial_input, 'Shell')
        self.assertEqual(self.menu.pattern, pattern)
        for line in serial_input.split('\n'):
            match = re.search(pattern, line)
            if match:
                if match.group(2) == "Shell":
                    self.assertEqual(match.group(1), selection)
Example #4
0
class TestSelectorMenu(unittest.TestCase):

    def setUp(self):
        self.menu = SelectorMenu()
        self.menu.item_markup = (r'\[', r'\]')
        self.menu.item_class = '0-9'
        self.menu.separator = ' '
        self.menu.label_class = 'a-zA-Z0-9'
        self.menu.prompt = None

    def test_menu_parser(self):
        pattern = "%s([%s]+)%s%s([%s]*)" % (
            re.escape(self.menu.item_markup[0]),
            self.menu.item_class,
            re.escape(self.menu.item_markup[1]),
            self.menu.separator,
            self.menu.label_class
        )
        serial_input = """
    [1] debian
    [2] tester
    [3] Shell
    [4] Boot Manager
    [5] Reboot
    [6] Shutdown
    Start:
            """
        selection = self.menu.select(serial_input, 'Shell')
        self.assertEqual(
            self.menu.pattern,
            pattern
        )
        for line in serial_input.split('\n'):
            match = re.search(pattern, line)
            if match:
                if match.group(2) == "Shell":
                    self.assertEqual(match.group(1), selection)