Exemple #1
0
def test_term_dice_with_flag_and_operator_invalid():
    token = term()
    with pytest.raises(ParseException):
        token.parseString("1d6!keeper+5")
    with pytest.raises(ParseException):
        token.parseString("1d6a!keep+5")
    with pytest.raises(ParseException):
        token.parseString("1d6!advant+5")
Exemple #2
0
def test_term_dice_only():
    parse_result = term().parseString("1d6")
    tokens = parse_result.asList()
    assert len(tokens) == 1

    actual = tokens.pop()
    expected = Dice(rolls=1, sides=6)
    assert actual == expected
Exemple #3
0
def test_term_dice_with_flag_and_operator_invalid():
    token = term()
    with pytest.raises(ParseException):
        token.parseString("1d6!keeper+5")
    with pytest.raises(ParseException):
        token.parseString("1d6a!keep+5")
    with pytest.raises(ParseException):
        token.parseString("1d6!advant+5")
Exemple #4
0
 def test_term_dice_with_flag_and_operator_invalid(self):
     token = term()
     with self.assertRaises(ParseException):
         actual = token.parseString("1d6!keeper+5")
     with self.assertRaises(ParseException):
         actual = token.parseString("1d6a!keep+5")
     with self.assertRaises(ParseException):
         actual = token.parseString("1d6!advant+5")
Exemple #5
0
def test_term_dice_only():
    parse_result = term().parseString("1d6")
    tokens = parse_result.asList()
    assert len(tokens) == 1

    actual = tokens.pop()
    expected = Dice(rolls=1, sides=6)
    assert actual == expected
Exemple #6
0
def test_term_dice_only_invalid():
    token = term()
    with pytest.raises(ParseException):
        token.parseString("1d1.2")
    with pytest.raises(ParseException):
        token.parseString("1d-6")
    with pytest.raises(ParseException):
        token.parseString("1t6")
Exemple #7
0
 def test_term_dice_only_invalid(self):
     token = term()
     with self.assertRaises(ParseException):
         actual = token.parseString("1d1.2")
     with self.assertRaises(ParseException):
         actual = token.parseString("1d-6")
     with self.assertRaises(ParseException):
         actual = token.parseString("1t6")
Exemple #8
0
def test_term_dice_only_invalid():
    token = term()
    with pytest.raises(ParseException):
        token.parseString("1d1.2")
    with pytest.raises(ParseException):
        token.parseString("1d-6")
    with pytest.raises(ParseException):
        token.parseString("1t6")
Exemple #9
0
 def test_term_dice_only_uppercase(self):
     token = term()
     actual = token.parseString("1D6")
     pprint(actual.asList())
     self.assertEqual(len(actual), 3)
     #NOTE:  this is the same as in test_term_dice_only as CaselessLiteral will
     # return the case of the defined matchString, not the search string passed
     # into parse.   -ZR
     self.assertEqual(actual.asList(), [1, 'd', 6])
Exemple #10
0
def test_term_dice_with_flag_and_operator():
    parse_result = term().parseString("1d6!keep+5")
    tokens = parse_result.asList()
    assert len(tokens) == 1

    actual = tokens.pop()
    expected = [[Dice(rolls=1, sides=6), "!keep"], "+", 5]
    assert len(actual) == 3
    assert actual == expected
Exemple #11
0
def test_term_dice_with_flag():
    parse_result = term().parseString("1d6!keep")
    tokens = parse_result.asList()
    assert len(tokens) == 1

    actual = tokens.pop()
    expected = [Dice(rolls=1, sides=6), "!keep"]
    assert len(actual) == 2
    assert actual == expected
Exemple #12
0
def test_term_dice_with_flag_and_operator():
    parse_result = term().parseString("1d6!keep+5")
    tokens = parse_result.asList()
    assert len(tokens) == 1

    actual = tokens.pop()
    expected = [[Dice(rolls=1, sides=6), "!keep"], "+", 5]
    assert len(actual) == 3
    assert actual == expected
Exemple #13
0
def test_term_dice_with_flag():
    parse_result = term().parseString("1d6!keep")
    tokens = parse_result.asList()
    assert len(tokens) == 1

    actual = tokens.pop()
    expected = [Dice(rolls=1, sides=6), "!keep"]
    assert len(actual) == 2
    assert actual == expected
Exemple #14
0
def test_term_dice_only_uppercase():
    # NOTE:  this is the same as in test_term_dice_only as CaselessLiteral will
    # return the case of the defined matchString, not the search string passed
    # into parse.   -ZR
    parse_result = term().parseString("1D6")
    tokens = parse_result.asList()
    assert len(tokens) == 1

    actual = tokens.pop()
    expected = Dice(rolls=1, sides=6)
    assert actual == expected
Exemple #15
0
def test_term_dice_only_uppercase():
    #NOTE:  this is the same as in test_term_dice_only as CaselessLiteral will
    # return the case of the defined matchString, not the search string passed
    # into parse.   -ZR
    parse_result = term().parseString("1D6")
    tokens = parse_result.asList()
    assert len(tokens) == 1

    actual = tokens.pop()
    expected = Dice(rolls=1, sides=6)
    assert actual == expected
Exemple #16
0
 def test_term_dice_only(self):
     token = term()
     actual = token.parseString("1d6")
     pprint(actual.asList())
     self.assertEqual(len(actual), 3)
     self.assertEqual(actual.asList(), [1, 'd', 6])
Exemple #17
0
 def test_term_dice_with_flag(self):
     token = term()
     actual = token.parseString("1d6!keep")
     pprint(actual.asList())
     self.assertEqual(len(actual), 4)
     self.assertEqual(actual.asList(), [1, 'd', 6, '!keep'])
Exemple #18
0
 def test_term_dice_with_operator(self):
     token = term()
     actual = token.parseString("1d6+5")
     pprint(actual.asList())
     self.assertEqual(len(actual), 5)
     self.assertEqual(actual.asList(), [1, 'd', 6, '+', 5])
Exemple #19
0
 def test_term_dice_with_flag_and_operator_uppercase(self):
     token = term()
     actual = token.parseString("1D6!KEEP+5")
     pprint(actual.asList())
     self.assertEqual(len(actual), 6)
     self.assertEqual(actual.asList(), [1, 'd', 6, '!keep', '+', 5])