def _test_attr(args): kwargs, expected_output_data, good_output_data = args[0:3] bad_output_data = args[4:] test = Test(assignment_id=42, output_data=expected_output_data, **kwargs) DBSession.add(test) DBSession.flush() test = DBSession.merge(test) for d in good_output_data: result, _, expected, output, _ = test.validate(d) converted_output = test.unconvert(test.convert(d)) assert result is True, (expected, output, converted_output) for d in bad_output_data: result, _, expected, output, _ = test.validate(d) converted_output = test.unconvert(test.convert(d)) assert result is False, (expected, output, converted_output)
def test_integration_2(self): test = Test( assignment_id=42, output_data=u'42 Bananas\n4711 Strawberrys\n1337 Apples\n', splitlines=True, sort=True, ) DBSession.add(test) DBSession.flush() test = DBSession.merge(test) d = u'#Result:\n4711 Strawberrys\n42 Bananas\n1337 Apples\n' result, _, expected, output, _ = test.validate(d) converted_output = test.unconvert(test.convert(d)) assert result is True, (expected, output, converted_output)
def test_integration_1(self): test = Test( assignment_id=42, output_data=u'1.0,2.0,3.0\n4.0,5.0,6.0\n7.0,8.0,9.0\n', separator=',', split=True, splitlines=True, parse_float=True, float_precision=1, ) DBSession.add(test) DBSession.flush() test = DBSession.merge(test) d = u'#Result:\n1,2,3\n4,5,6\n,7,8,9\n' result, _, expected, output, _ = test.validate(d) converted_output = test.unconvert(test.convert(d)) assert result is True, (expected, output, converted_output)