From db1a137f713f714d55e3b93aaef16c4605d19688 Mon Sep 17 00:00:00 2001 From: Statute8234 <76547158+Statute8234@users.noreply.github.com> Date: Wed, 10 Apr 2024 16:05:04 -0400 Subject: [PATCH] Update test_module.py According to PEP 8 Maximum Line Length is a maximum of 79 characters. This edit is reducing the sizes of the lines in general. --- test_module.py | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/test_module.py b/test_module.py index 16424a63b..b6714820d 100644 --- a/test_module.py +++ b/test_module.py @@ -1,6 +1,8 @@ import unittest + import demographic_data_analyzer + class DemographicAnalyzerTestCase(unittest.TestCase): @classmethod def setUpClass(self): @@ -9,52 +11,63 @@ def setUpClass(self): def test_race_count(self): actual = self.data['race_count'].tolist() expected = [27816, 3124, 1039, 311, 271] - self.assertCountEqual(actual, expected, msg="Expected race count values to be [27816, 3124, 1039, 311, 271]") - + race_message = "Expected race count values to be {}".format(expected) + self.assertCountEqual(actual, expected, msg=race_message) + def test_average_age_men(self): actual = self.data['average_age_men'] expected = 39.4 - self.assertAlmostEqual(actual, expected, msg="Expected different value for average age of men.") + average_message = "Expected different value for average age of men." + self.assertAlmostEqual(actual, expected, msg=average_message) def test_percentage_bachelors(self): actual = self.data['percentage_bachelors'] expected = 16.4 - self.assertAlmostEqual(actual, expected, msg="Expected different value for percentage with Bachelors degrees.") + percentage_message = "Expected different value for percentage with Bachelors degrees." + self.assertAlmostEqual(actual, expected, msg=percentage_message) def test_higher_education_rich(self): actual = self.data['higher_education_rich'] expected = 46.5 - self.assertAlmostEqual(actual, expected, msg="Expected different value for percentage with higher education that earn >50K.") + higher_message = "Expected different value for percentage with higher education that earn >50K." + self.assertAlmostEqual(actual, expected, msg=higher_message) def test_lower_education_rich(self): actual = self.data['lower_education_rich'] expected = 17.4 - self.assertAlmostEqual(actual, expected, msg="Expected different value for percentage without higher education that earn >50K.") + test_lower_message = "Expected different value for percentage without higher education that earn >50K.") + self.assertAlmostEqual(actual, expected, msg=test_lower_message) def test_min_work_hours(self): actual = self.data['min_work_hours'] expected = 1 - self.assertAlmostEqual(actual, expected, msg="Expected different value for minimum work hours.") + test_min_message = "Expected different value for minimum work hours." + self.assertAlmostEqual(actual, expected, msg=test_min_message) def test_rich_percentage(self): actual = self.data['rich_percentage'] expected = 10 - self.assertAlmostEqual(actual, expected, msg="Expected different value for percentage of rich among those who work fewest hours.") + test_rich_message = "Expected different value for percentage of rich among those who work fewest hours." + self.assertAlmostEqual(actual, expected, msg=test_rich_message) def test_highest_earning_country(self): actual = self.data['highest_earning_country'] expected = 'Iran' - self.assertEqual(actual, expected, "Expected different value for highest earning country.") + highest_earning_string = "Expected different value for highest earning country." + self.assertEqual(actual, expected, highest_earning_string) def test_highest_earning_country_percentage(self): actual = self.data['highest_earning_country_percentage'] expected = 41.9 - self.assertAlmostEqual(actual, expected, msg="Expected different value for highest earning country percentage.") + test_highest_message = "Expected different value for highest earning country percentage." + self.assertAlmostEqual(actual, expected, msg=test_highest_message) def test_top_IN_occupation(self): actual = self.data['top_IN_occupation'] expected = 'Prof-specialty' - self.assertEqual(actual, expected, "Expected different value for top occupations in India.") + top_IN_string = "Expected different value for top occupations in India." + self.assertEqual(actual, expected, top_IN_string) + if __name__ == "__main__": unittest.main()