def test_create_plots_files(self): """ Creates the plots for the 2007 year Result: Should create 7 plots """ try: os.remove('2007_WORLD_boxplot.pdf') os.remove('AFRICA_2007_income_per_person.pdf') os.remove('ASIA_2007_income_per_person.pdf') os.remove('EUROPE_2007_income_per_person.pdf') os.remove('NORTH AMERICA_2007_income_per_person.pdf') os.remove('OCEANIA_2007_income_per_person.pdf') os.remove('SOUTH AMERICA_2007_income_per_person.pdf') except IOError: pass year = 2007 countries_filename = 'countries.csv' income_filename = ['indicator gapminder gdp_per_capita_ppp.xlsx', 'Data'] countries, income = load_dataframes(countries_filename, income_filename) #Creates the merged file countries_merged_df = merge_by_year(income, countries, year) #Creates the object plotting = AreaIncomeGraphs(year, countries_merged_df) plotting.create_plots() self.assertTrue(os.path.isfile('2007_WORLD_boxplot.pdf')) self.assertTrue(os.path.isfile('AFRICA_2007_income_per_person.pdf')) self.assertTrue(os.path.isfile('ASIA_2007_income_per_person.pdf')) self.assertTrue(os.path.isfile('EUROPE_2007_income_per_person.pdf')) self.assertTrue(os.path.isfile('NORTH AMERICA_2007_income_per_person.pdf')) self.assertTrue(os.path.isfile('OCEANIA_2007_income_per_person.pdf')) self.assertTrue(os.path.isfile('SOUTH AMERICA_2007_income_per_person.pdf'))
user_input = raw_input("Insert Year: ") if user_input == 'finish': year_flag = False else: try: #Try to cast the input to Integer user_year = int(user_input) if 1800 <= user_year <= 2012: get_hist_income_per_year(income, user_year) else: print "Enter a year between 1800 and 2012" except ValueError: print "Please insert a valid year" print "Generating Plots from 2007-2012..." try: for year in range(2007, 2013, 1): #Creates the merged file countries_merged_df = merge_by_year(income, countries, year) #Creates the object plotting = AreaIncomeGraphs(year, countries_merged_df) plotting.create_plots() except ValueError as valueerror_message: print valueerror_message except IOError as ioerror_message: print ioerror_message except LookupError as lookuperror_message: print lookuperror_message