Ejemplo n.º 1
0
def test_should_return_boolean():
    result = Dice().__gt__(Dice())

    assert isinstance(result, bool) is True
Ejemplo n.º 2
0
def test_should_return_false_when_other_dice_is_greater():
    result = Dice(sides=2).__gt__(Dice(sides=20))

    assert result is False
Ejemplo n.º 3
0
def test_should_return_true_when_other_dice_is_lower():
    result = Dice(sides=20).__gt__(Dice(sides=2))

    assert result is True
Ejemplo n.º 4
0
def test_should_return_last_roll():
    dice = Dice()
    dice.last_roll = 8
    assert dice.__len__() == 8
Ejemplo n.º 5
0
def test_should_raise_type_error_when_not_dice_object():
    with pytest.raises(TypeError) as err:
        Dice().__gt__(object)

    assert str(err.value) == 'Operation only allowed between Dice\'s instances'
Ejemplo n.º 6
0
def test_should_return_true_when_same_number_of_sides():
    dice = Dice(sides=10)

    assert Dice(sides=10).__eq__(dice) is True
Ejemplo n.º 7
0
def test_should_return_false_when_not_a_dice_instance():
    assert Dice().__eq__(object) is False
Ejemplo n.º 8
0
def test_should_raise_type_error_when_not_int():
    with pytest.raises(TypeError) as err:
        Dice().__mul__(object)

    assert str(err.value) == 'Unsupported operand type(s) for *'
Ejemplo n.º 9
0
def test_should_call_roll_multiple_times(mock_roll):
    result = Dice(sides=10).__mul__(3)

    assert mock_roll.call_count == 3
    assert result == [mock_roll.return_value] * 3
Ejemplo n.º 10
0
def test_should_return_true_when_other_dice_is_equal():
    result = Dice(20).__ge__(Dice(20))

    assert result is True