Skip to content

Commit e9d5731

Browse files
committed
added new tests for dice rolling
1 parent 65a53ba commit e9d5731

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

docs/index.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ The program also provides an API for rolling dice using the ```mc.Roll()``` clas
136136
```python
137137
roll = mc.Roll() # instantiate the Roll() class
138138

139-
roll.four()
139+
# now you can call dice rolls
140+
roll.four()
140141
roll.six()
141142
roll.eight()
142143
roll.ten()

tests/test_mercutio.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,35 @@ def test_gen():
1414
assert isinstance(player.attributes, (dict))
1515
assert isinstance(player.skills, (dict))
1616

17-
17+
# test that overwriting player dimensions works as expected
1818
def test_load_dimensions_append():
1919
player = mc.Player()
2020
player.load_dimensions(how='append', player_class=['wizard', 'general', 'edain'])
2121

2222
assert len(player.player_class_options) == 7
2323

24+
# test that overwriting player dimensions works as expected
2425
def test_load_dimensions_overwrite():
2526
player = mc.Player()
2627
player.load_dimensions(how='overwrite', player_class=['wizard', 'general', 'edain'])
2728

2829
assert len(player.player_class_options) == 3
2930

31+
# test that modifications to player stats work as expected
3032
def test_mod():
3133
player = mc.Player()
3234
player.gen(name='balthor batwing, earl of pentham',)
3335

3436
player.mod(name='beringor barthenon, guardian of bradley gardens')
3537

3638
assert player.name == 'beringor barthenon, guardian of bradley gardens'
39+
40+
# test that dice-rolls return values w/i expected ranges
41+
def test_dice():
42+
roll = mc.Roll() # instantiate the Roll() class
43+
44+
assert all([roll.four() for _ in range(100)]) in range(1,5)
45+
assert all([roll.eight() for _ in range(100)]) in range(1,9)
46+
assert all([roll.ten() for _ in range(100)]) in range(1,11)
47+
assert all([roll.twelve() for _ in range(100)]) in range(1,13)
48+
assert all([roll.twenty() for _ in range(100)]) in range(1,21)

0 commit comments

Comments
 (0)