Skip to content

Commit 77ee876

Browse files
committed
Corrected tests docstring and cleaned up tests
1 parent 6a1eddc commit 77ee876

13 files changed

Lines changed: 163 additions & 156 deletions

tests/parser/dice/test_dice_parser_dice.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
class TestSimpleDice(unittest.TestCase):
1717
"""
18-
Tests that simple dice expressions can be parsed into the Dice class.
18+
Tests that simple dice expressions can be parsed.
1919
"""
2020

2121
def setUp(self):
@@ -33,9 +33,9 @@ def test_simpleDice(self):
3333
self.assertEqual(1, dice.quantity)
3434
self.assertEqual(6, dice.sides)
3535

36-
def test_simpleDice_alternativeSeparator(self):
36+
def test_simpleDice_upperCaseSeparator(self):
3737
"""
38-
Tests that a simple dice notation can be parsed.
38+
Tests that the upper case dice separator can be parsed.
3939
"""
4040
dice = self.parser.parse("1D6")
4141

@@ -44,7 +44,7 @@ def test_simpleDice_alternativeSeparator(self):
4444

4545
def test_onesDice(self):
4646
"""
47-
Tests that a simple dice notation can be parsed.
47+
Tests that dice notation with a single dice and a single side can be parsed.
4848
"""
4949
dice = self.parser.parse("1d1")
5050

@@ -53,7 +53,7 @@ def test_onesDice(self):
5353

5454
def test_zeroQuantity(self):
5555
"""
56-
Tests that a simple dice notation can be parsed.
56+
Tests that dice notation with zero dice is parsed.
5757
"""
5858
dice = self.parser.parse("0d6")
5959

@@ -62,7 +62,7 @@ def test_zeroQuantity(self):
6262

6363
def test_zeroSides(self):
6464
"""
65-
Tests that a simple dice notation can be parsed.
65+
Tests that dice notation with zero sides is parsed.
6666
"""
6767
dice = self.parser.parse("1d0")
6868

@@ -71,7 +71,7 @@ def test_zeroSides(self):
7171

7272
def test_zerosDice(self):
7373
"""
74-
Tests that a simple dice notation can be parsed.
74+
Tests that dice notation with zero dice and zero sides is parsed.
7575
"""
7676
dice = self.parser.parse("0d0")
7777

@@ -80,7 +80,7 @@ def test_zerosDice(self):
8080

8181
def test_max(self):
8282
"""
83-
Tests that a simple dice notation can be parsed.
83+
Tests that dice notation with the maximum integer values dice is parsed.
8484
"""
8585
dice = self.parser.parse(str(sys.maxsize) + "d" + str(sys.maxsize))
8686

tests/parser/dice/test_dice_parser_dice_binary_operation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from dice_notation.parser import DiceParser
66

77
"""
8-
Dice parser tests for expressions only containing dice.
8+
Dice parser tests for binary operation expressions only containing dice.
99
"""
1010

1111
__author__ = 'Bernardo Martínez Garrido'
@@ -14,7 +14,7 @@
1414

1515
class TestDiceBinaryOperation(unittest.TestCase):
1616
"""
17-
Tests that the parser can work with pure numeric operations.
17+
Tests that binary operation dice expressions can be parsed.
1818
"""
1919

2020
def setUp(self):
@@ -25,7 +25,7 @@ def setUp(self):
2525

2626
def test_add(self):
2727
"""
28-
Tests that numeric additions are done correctly.
28+
Tests that dice additions can be parsed.
2929
"""
3030
result = self.parser.parse("1d6+2d20")
3131

@@ -40,7 +40,7 @@ def test_add(self):
4040

4141
def test_sub(self):
4242
"""
43-
Tests that numeric subtractions are done correctly.
43+
Tests that dice subtractions can be parsed.
4444
"""
4545
result = self.parser.parse("3d12-1D6")
4646

tests/parser/dice/test_dice_parser_dice_rollable.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from dice_notation.parser import DiceParser
77

88
"""
9-
Dice parser tests for expressions only containing dice.
9+
Dice parser tests for dice expressions, validating the output class.
1010
"""
1111

1212
__author__ = 'Bernardo Martínez Garrido'
@@ -15,7 +15,7 @@
1515

1616
class TestRollable(unittest.TestCase):
1717
"""
18-
Tests that the parser can work with pure numeric operations.
18+
Tests that dice expressions return instances of Rollable.
1919
"""
2020

2121
def setUp(self):
@@ -26,23 +26,23 @@ def setUp(self):
2626

2727
def test_simpleDice_rollable(self):
2828
"""
29-
Tests that a simple dice notation can be parsed.
29+
Tests that parsing simple dice notation returns a Rollable.
3030
"""
3131
dice = self.parser.parse("1d6")
3232

3333
self.assertTrue(isinstance(dice, Rollable))
3434

3535
def test_add_rollable(self):
3636
"""
37-
Tests that numeric additions are done correctly.
37+
Tests that parsing dice notation additions return a Rollable.
3838
"""
3939
result = self.parser.parse("1d6+2d20")
4040

4141
self.assertTrue(isinstance(result, Rollable))
4242

4343
def test_sub_rollable(self):
4444
"""
45-
Tests that numeric subtractions are done correctly.
45+
Tests that parsing dice notation subtractions return a Rollable.
4646
"""
4747
result = self.parser.parse("3d12-1D6")
4848

tests/parser/number/test_dice_parser_number.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
class TestNumber(unittest.TestCase):
1616
"""
17-
Tests that the parser can work with pure numeric operations.
17+
Tests that numeric expressions can be parsed.
1818
"""
1919

2020
def setUp(self):
@@ -25,23 +25,23 @@ def setUp(self):
2525

2626
def test_positive(self):
2727
"""
28-
Tests that numeric additions are done correctly.
28+
Tests that positive numbers can be parsed.
2929
"""
3030
result = self.parser.parse("5")
3131

3232
self.assertEqual(5, result)
3333

3434
def test_zero(self):
3535
"""
36-
Tests that numeric additions are done correctly.
36+
Tests that the zero value can be parsed.
3737
"""
3838
result = self.parser.parse("0")
3939

4040
self.assertEqual(0, result)
4141

4242
def test_negative(self):
4343
"""
44-
Tests that numeric additions are done correctly.
44+
Tests that negative numbers can be parsed.
4545
"""
4646
result = self.parser.parse("-5")
4747

tests/parser/number/test_dice_parser_number_add.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from dice_notation.parser import DiceParser
66

77
"""
8-
Dice parser tests for purely numeric expressions.
8+
Dice parser tests for purely numeric addition expressions.
99
"""
1010

1111
__author__ = 'Bernardo Martínez Garrido'
@@ -14,7 +14,7 @@
1414

1515
class TestAdd(unittest.TestCase):
1616
"""
17-
Tests that the parser can work with pure numeric operations.
17+
Tests that numeric addition expressions can be parsed.
1818
"""
1919

2020
def setUp(self):
@@ -25,15 +25,15 @@ def setUp(self):
2525

2626
def test_add(self):
2727
"""
28-
Tests that numeric additions are done correctly.
28+
Tests that additions can be parsed, and the result is the expected one.
2929
"""
3030
result = self.parser.parse("1+2")
3131

3232
self.assertEqual(3, result)
3333

3434
def test_add_toNegative(self):
3535
"""
36-
Tests that numeric additions are done correctly.
36+
Tests that additions to a negative value can be parsed, and the result is the expected one.
3737
"""
3838
result = self.parser.parse("-1+2")
3939

@@ -43,7 +43,7 @@ def test_add_toNegative(self):
4343

4444
class TestAddLong(unittest.TestCase):
4545
"""
46-
Tests that the parser can work with pure numeric operations.
46+
Tests that long numeric addition expressions can be parsed.
4747
"""
4848

4949
def setUp(self):
@@ -54,15 +54,15 @@ def setUp(self):
5454

5555
def test_longAdd(self):
5656
"""
57-
Tests that numeric additions are done correctly.
57+
Tests that long additions can be parsed, and the result is the expected one.
5858
"""
5959
result = self.parser.parse("1+2+3")
6060

6161
self.assertEqual(6, result)
6262

6363
def test_longerAdd(self):
6464
"""
65-
Tests that numeric additions are done correctly.
65+
Tests that longer additions can be parsed, and the result is the expected one.
6666
"""
6767
result = self.parser.parse("1+2+3+4+5")
6868

tests/parser/number/test_dice_parser_number_binary_op_mixed.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
from dice_notation.parser import DiceParser
66

77
"""
8-
Dice parser tests for purely numeric expressions.
8+
Dice parser tests for mixed numeric binary operation expressions.
9+
10+
A mixer operation contains additions and subtractions.
911
"""
1012

1113
__author__ = 'Bernardo Martínez Garrido'
@@ -14,7 +16,7 @@
1416

1517
class TestNumericBinaryOperationMixed(unittest.TestCase):
1618
"""
17-
Tests that the parser can work with pure numeric operations.
19+
Tests that mixed numeric binary operation expressions can be parsed.
1820
"""
1921

2022
def setUp(self):
@@ -25,15 +27,15 @@ def setUp(self):
2527

2628
def test_addAndSub(self):
2729
"""
28-
Tests that numeric additions are done correctly.
30+
Tests that additions followed by subtractions can be parsed, and the result is the expected one.
2931
"""
3032
result = self.parser.parse("1+2-3")
3133

3234
self.assertEqual(0, result)
3335

3436
def test_subAndAdd(self):
3537
"""
36-
Tests that numeric subtractions are done correctly.
38+
Tests that subtractions followed by additions can be parsed, and the result is the expected one.
3739
"""
3840
result = self.parser.parse("3-1+2")
3941

tests/parser/number/test_dice_parser_number_rollable.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from dice_notation.parser import DiceParser
77

88
"""
9-
Dice parser tests for purely numeric expressions.
9+
Dice parser tests for numeric expressions, validating the output class.
1010
"""
1111

1212
__author__ = 'Bernardo Martínez Garrido'
@@ -15,7 +15,7 @@
1515

1616
class TestRollable(unittest.TestCase):
1717
"""
18-
Tests that the parser can work with pure numeric operations.
18+
Tests that numeric expressions return instances of Rollable.
1919
"""
2020

2121
def setUp(self):
@@ -26,23 +26,23 @@ def setUp(self):
2626

2727
def test_number_rollable(self):
2828
"""
29-
Tests that a simple dice notation can be parsed.
29+
Tests that parsing numbers returns a Rollable.
3030
"""
3131
result = self.parser.parse("1")
3232

3333
self.assertTrue(isinstance(result, Rollable))
3434

3535
def test_add_rollable(self):
3636
"""
37-
Tests that a simple dice notation can be parsed.
37+
Tests that parsing numeric additions returns a Rollable.
3838
"""
3939
result = self.parser.parse("1+2")
4040

4141
self.assertTrue(isinstance(result, Rollable))
4242

4343
def test_sub_rollable(self):
4444
"""
45-
Tests that a simple dice notation can be parsed.
45+
Tests that parsing numeric subtractions returns a Rollable.
4646
"""
4747
result = self.parser.parse("1-2")
4848

@@ -51,7 +51,7 @@ def test_sub_rollable(self):
5151

5252
class TestRoll(unittest.TestCase):
5353
"""
54-
Tests that the parser can work with pure numeric operations.
54+
Tests that rolling the result from parsing numeric expressions returns the expected value.
5555
"""
5656

5757
def setUp(self):
@@ -60,25 +60,25 @@ def setUp(self):
6060
"""
6161
self.parser = DiceParser()
6262

63-
def test_number_rollable(self):
63+
def test_number_roll(self):
6464
"""
65-
Tests that a simple dice notation can be parsed.
65+
Tests that rolling a parsed number returns the expected value.
6666
"""
6767
result = self.parser.parse("1")
6868

6969
self.assertEqual(1, result.roll())
7070

71-
def test_add_rollable(self):
71+
def test_add_roll(self):
7272
"""
73-
Tests that a simple dice notation can be parsed.
73+
Tests that rolling a parsed numeric addition returns the expected value.
7474
"""
7575
result = self.parser.parse("1+2")
7676

7777
self.assertEqual(3, result.roll())
7878

79-
def test_sub_rollable(self):
79+
def test_sub_roll(self):
8080
"""
81-
Tests that a simple dice notation can be parsed.
81+
Tests that rolling a parsed numeric subtraction returns the expected value.
8282
"""
8383
result = self.parser.parse("1-2")
8484

0 commit comments

Comments
 (0)