class TestPassengers(TestCase):
    def setUp(self):
        self.pas = Passengers('test_passengers_data.csv')

    def test_sum_male(self):
        self.assertEquals(self.pas.sum_male(), 1)

    def test_sum_female(self):
        self.assertEquals(self.pas.sum_female(), 4)

    def test_percent_of_surviving(self):
        self.assertEquals(self.pas.percent_of_surviving(), 50)

    def test_mean_age_of_passenger(self):
        self.assertEquals(self.pas.mean_age_of_passenger(), 3)

    def test_median_age_of_passenger(self):
        self.assertEquals(self.pas.median_age_of_passenger(), 2)

    def test_percent_of_first_class(self):
        self.assertEquals(self.pas.percent_of_first_class(), 50)

    def test_most_popular_female_name(self):
        self.assertEquals(self.pas.most_popular_female_name(), ('Mary', 3))

    def test_probability_of_surviving(self):
        self.assertEquals(self.pas.probability_of_surviving(2, 1, 'female'), 47.222222222222214)
Exemple #2
0
    def test_passengers_integration(self):
        passengers = Passengers(c.SAMPLE_DATA)

        assert passengers.header == c.HEADERS
        for feature, value in passengers.feature_sets.items():
            assert Counter(c.FEATURE_SETS[feature]) == Counter(value)
        assert len(passengers.feature_sets) == len(c.FEATURE_SETS)
Exemple #3
0
from passengers import Passengers
from traxi import Traxi
from check_inputs import check_inputs


if __name__ == "__main__":
    check_inputs()

    p = Passengers()
    t = Traxi()
    while True:
        new_passenger = p.generate()
        t.manage(new_passenger)
 def setUp(self):
     self.pas = Passengers('test_passengers_data.csv')