def set_up(self): self.otter = Otter([]) self.test_object = test_class() self.otter.set_test_list( [self.test_object] ) self.otter.log_success({"Success Test": "Success Test"})
class LogSuccessTest(UnitTest): def set_up(self): self.otter = Otter([]) self.test_object = test_class() self.otter.set_test_list( [self.test_object] ) self.otter.log_success({"Success Test": "Success Test"}) def tear_down(self): self.otter = None @TestCase def test_success_count(self): assert_true(self.otter.get_success_count() == 1) @TestCase def test_success_result(self): assert_true( self.otter.get_results()[0] == {"Success Test": "Success Test"}, message="Expected True and got False." ) @TestCase def test_result_length(self): assert_true( len(self.otter.get_results()) == 1, message="Expected True and got False." )
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 set_up(self): self.otter = Otter([]) self.test_object = test_class() self.otter.set_test_list( [self.test_object] ) self.otter.get_test_list()[0].set_up() self.unit = self.otter.get_test_list()[0] self.case = { "func": test_class.test_case_two, "name": "test_case_two" } self.otter.execute_test(self.unit, self.case) self.result = self.otter.get_results()[0]
class ExecuteTestFailureTest(UnitTest): def set_up(self): self.otter = Otter([]) self.test_object = test_class() self.otter.set_test_list( [self.test_object] ) self.otter.get_test_list()[0].set_up() self.unit = self.otter.get_test_list()[0] self.case = { "func": test_class.test_case_two, "name": "test_case_two" } self.otter.execute_test(self.unit, self.case) self.result = self.otter.get_results()[0] def tear_down(self): self.otter = None @TestCase def test_execute_test_status(self): assert_equal( self.result["status"], Status.FAIL, message="Status was not OK." ) @TestCase def test_execute_test_message(self): assert_equal( self.result["message"], "I Failed." ) @TestCase def test_execute_test_unit(self): assert_is( self.result["unit"], self.unit ) @TestCase def test_execute_test_case(self): assert_is( self.result["case"], self.case["name"] )
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." )
def set_up(self): self.otter = Otter([]) self.test_object = test_class() self.otter.set_test_list([self.test_object]) self.otter.log_fail({"Failed Test": "Failed Test"})
try: 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)