def test_parse_uppercases(self):
     # Arrange
     txt_succ = 'ABCabc'
     txt_fail = 'abc'
     parser = stp.parse_uppercases()
     parser_label = stp.parse_uppercases('spam')
     # Act
     res_succ = parser(txt_succ)
     res_fail = parser(txt_fail)
     exp_succ = res.Success.unit(("ABC", "abc"))
     exp_fail = res.Failure.unit("error")
     # Assert
     self.assertEqual(res_succ, exp_succ)
     self.assertEqual(res_fail, exp_fail)
     self.assertEqual(parser.label, '[A-Z]+')
     self.assertEqual(parser_label.label, 'spam')
 def test_FailureCase(self):
     # Arrange
     txt = 'ABCabc123 lorem ipsum'
     parser_l = stp.parse_uppercases()
     parser_m = stp.parse_digits()
     parser_r = stp.parse_lowercases()
     parser = cmb.betweenparsers(parser_l, parser_m, parser_r)
     # Act
     result = parser(txt)
     expected = res.Failure('error')
     # Assert
     self.assertEqual(result, expected)
 def test_SuccessCase(self):
     # Arrange
     txt = 'ABCabc123 lorem ipsum'
     parser_l = stp.parse_uppercases()
     parser_m = stp.parse_lowercases()
     parser_r = stp.parse_digits()
     parser = cmb.betweenparsers(parser_l, parser_m, parser_r)
     # Act
     result = parser(txt)
     expected = res.Success(('abc', ' lorem ipsum'))
     # Assert
     self.assertEqual(result, expected)