예제 #1
0
    def test_div(self):
        train_1 = Speed(mile__hour=10)
        divider = 2

        actual_value = train_1 / divider
        expected_value = Speed(mile__hour=5)

        assert expected_value == actual_value
예제 #2
0
    def test_addition(self):
        train_1 = Speed(mile__hour=10)
        train_2 = Speed(mile__hour=5)

        actual_value = train_1 + train_2
        expected_value = Speed(mile__hour=15)

        assert actual_value == expected_value
예제 #3
0
    def test_sub(self):
        train_1 = Speed(mile__hour=10)
        train_2 = Speed(mile__hour=5)

        expected_value = Speed(mile__hour=5)
        actual_value = train_1 - train_2

        assert expected_value == actual_value
예제 #4
0
    def test_mul(self):
        train_1 = Speed(mile__hour=10)
        multiplier = 2

        actual_value = multiplier * train_1
        expected_value = Speed(mile__hour=20)

        assert expected_value == actual_value
예제 #5
0
    def test_iadd(self):
        train_1 = Speed(mile__hour=10)
        train_2 = Speed(mile__hour=5)

        actual_value = train_1
        actual_value += train_2
        expected_value = Speed(mile__hour=15)

        assert actual_value == expected_value
예제 #6
0
    def test_bool_true(self):
        train_1 = Speed(mile__hour=5)

        assert train_1
예제 #7
0
    def test_lt(self):
        train_1 = Speed(mile__hour=5)
        train_2 = Speed(mile__hour=10)

        assert train_1 < train_2
예제 #8
0
    def test_equals(self):
        train_1 = Speed(mile__hour=10)
        train_2 = Speed(mile__hour=10)

        assert train_1 == train_2
예제 #9
0
 def test_attrconversion(self):
     assert Speed("10 m/s") == Speed("36 km/h")
예제 #10
0
 def test_kph(self):
     assert Speed(kph=10) == Speed(km__h=10), Speed._units["km__h"].factor
예제 #11
0
 def test_mph(self):
     assert Speed(mph=10) == Speed(mi__h=10), Speed._units["mi__h"].factor
예제 #12
0
    def test_different_units_addition(self):
        train = Speed(km__h=1)
        increase = Speed(m__h=10)

        assert train + increase == Speed("1.01 km/h")
예제 #13
0
    def test_abbreviations(self):
        train_1 = Speed(mph=4)
        train_2 = Speed(mile__hour=4)

        assert train_1 == train_2
예제 #14
0
    def test_bool_false(self):
        train_1 = Speed(mile__hour=0)

        assert not train_1