def blog(name=None): """Handles requests coming in to the page.""" tests = request.args.get('body') page_title = "OTTER" otter = Otter(parse_units(tests)) otter.run() form = ConfigForm(csrf_enabled=False) content = otter.get_results() try: outcsv = open("results/out.csv", 'w') outtxt = open("results/out.txt", 'w') outcsv.write(otter.get_csv_output()) outtxt.write(otter.get_table()) except Exception as e: print(e) else: outcsv.close() outtxt.close() return render_template('result', title=page_title, body=content, runtime="", form=form)
class AppendUnitTest(UnitTest): def set_up(self): self.otter = Otter([]) self.test_object = test_class() self.otter.set_test_list( [self.test_object] ) self.otter.run() self.otter.append_test_unit_list({ "class": "test_class_2", "module": "test.append_unit_test" }) def tear_down(self): self.otter = None @TestCase def test_append_test_unit_list(self): assert_type_in( test_class_2, self.otter.unitTestInstanceList, message="Expected class, test_class_2, not present." )
file = open(args["infile"], 'r') for line in file: unittests.append(line) except Exception as e: print("Unable to open input file.", e) else: file.close() # Check if unit tests were provided. elif not args['unittests'] is None: unittests = args["unittests"] else: parser.parse_args(['-h']) # Parse unittests list. Then create and run the Otter object otter = Otter(parse_units(unittests)) otter.run() output = get_output(args["format"], otter) # Get the output. # Determine if file output is requested and either print to file or # to the screen. if not args["outfile"] is None: try: file = open(args["outfile"], 'w') file.write(output) except Exception as e: print("Unable to create file at given locaiton. ", e) else: file.close() else: print(output)