def test_can_write_xlsx(self): rows_to_write = ( ('a', 'b', 'c'), (1, 2, 3), ) test_build_folder = dev_test.path_to_test_folder('build') _tools.mkdirs(test_build_folder) xlsx_path = os.path.join(test_build_folder, 'test_can_write_xlsx.xlsx') with rowio.XlsxRowWriter(xlsx_path) as xlsx_writer: for row_to_write in rows_to_write: xlsx_writer.write_row(row_to_write) for row_index, row_read in enumerate(rowio.excel_rows(xlsx_path)): string_row_written = [six.text_type(item) for item in rows_to_write[row_index]] self.assertEqual(string_row_written, row_read)
def test_can_validate_many_customers(self): target_base_path = os.path.join("build", "site", "reports") item_name = "profile_lots_of_customers" target_profile_path = os.path.join(target_base_path, item_name) + ".profile" target_report_path = os.path.join(target_base_path, item_name) + ".txt" _tools.mkdirs(os.path.dirname(target_report_path)) profile.run( "from tests import test_performance; test_performance._build_and_validate_many_customers()", target_profile_path) with io.open(target_report_path, "w", encoding='utf-8') as targetReportFile: stats = pstats.Stats(target_profile_path, stream=targetReportFile) # HACK: With Python 2, avoid TypeError: must be unicode, not str if not six.PY2: stats.sort_stats("cumulative").print_stats("cutplace", 20)