Ejemplo n.º 1
0
    def test_remain_error_statements(self):

        confs = self._generate_conf(['false', 'true', 'error'])
        switch(confs=confs, remain=True)
        self.assertEqual(self.count_by_indexes[0], 0)
        self.assertEqual(self.count_by_indexes[1], 1)
        self.assertEqual(self.count_by_indexes[2], 1)
Ejemplo n.º 2
0
    def test_all_statements(self):

        confs = self._generate_conf(['true', 'false', 'true'])
        switch(confs=confs, all_checked=True, _default='count')
        self.assertEqual(self.count_by_indexes[0], 1)
        self.assertEqual(self.count_by_indexes[1], 0)
        self.assertEqual(self.count_by_indexes[2], 1)
        self.assertEqual(self.count_by_indexes['default'], 1)
Ejemplo n.º 3
0
    def test_one_false_statement(self):
        """
        Test a switch with one statement.
        """

        confs = self._generate_conf(['false'])
        switch(confs=confs)
        self.assertEqual(self.count_by_indexes[0], 0)
Ejemplo n.º 4
0
    def test_one_false_statement_with_default(self):
        """
        Test a switch with one statement.
        """

        confs = self._generate_conf(['false'])
        switch(confs=confs, _default='count')
        self.assertEqual(self.count_by_indexes[0], 0)
        self.assertEqual(self.count_by_indexes['default'], 1)
Ejemplo n.º 5
0
    def test_empty_switch_with_default(self):
        """
        Test empty switch.
        """

        result = switch(_default='count')
        self.assertIs(result, self)
Ejemplo n.º 6
0
    def test_empty_switch(self):
        """
        Test empty switch.
        """

        result = switch()
        self.assertIsNone(result, None)