def _format_values(self): returned = '[' for label, value in izip_longest(self.labels, self.values): assert value is not None if label is None: returned += repr(value) else: returned += 'slash.param({!r}, {!r})'.format(label, value) returned += ', ' returned += ']' return returned
def _verify_results(self, session, stop_on_error): results = list(session.results.iter_test_results()) results.sort(key=lambda result: result.test_metadata.fqn.address_in_module.method_name) should_be_run = True for result, test in izip_longest(results, self.tests): if should_be_run: test.verify_result(result) else: assert not result.is_started() assert result.is_skip() if result.is_error() or result.is_failure() and stop_on_error: should_be_run = False return session.results
def test_function_name_with_special_parameters(test_type): suite = Suite() assert len(suite) == 0 suite_test = suite.add_test(type=test_type) values = ['a.b', 'a(b'] suite_test.add_parameter(values=values) # we can't verify result because we would not be able to parse the function properly # TODO: this will change once we properly support variations metadata summary = suite.run(verify=False, sort=False) for result, value in izip_longest(summary.session.results, values): function_name = result.test_metadata.function_name assert value not in function_name assert '.' not in result.test_metadata.function_name assert '(' not in result.test_metadata.function_name assert function_name.startswith('test_')
def test_function_name_with_special_parameters(test_type): suite = Suite() assert len(suite) == 0 suite_test = suite.add_test(type=test_type) values = ['a.b', 'a(b'] suite_test.add_parameter(values=values) # we can't verify result because we would not be able to parse the function properly # TODO: this will change once we properly support variations metadata summary = suite.run(verify=False, sort=False) for result, value in izip_longest(summary.session.results, values): function_name = result.test_metadata.function_name assert value not in function_name assert '.' not in result.test_metadata.function_name assert '(' not in result.test_metadata.function_name assert function_name.startswith('test_')
def test_parametrization_labels(suite, suite_test): param = suite_test.add_parameter() param.add_labels() @suite_test.append_body def __code__(): # pylint: disable=unused-variable # pylint: disable=undefined-variablepylint: disable=no-member, protected-access, undefined-variable slash.context.result.data['params'] = locals().copy() slash.context.result.data['params'].pop('self', None) res = suite.run() for label, value, result in izip_longest( param.labels, param.values, res.get_all_results_for_test(suite_test)): assert label assert value assert result #assert result.test_metadata.variation.id[param.name] == label assert result.data['params'] == {param.name: value} assert label in result.test_metadata.address
def errors(self, errors_list): for res, error in izip_longest(self._results, errors_list): errs = res.get_errors() assert len(errs) == 1 assert errs[0] == error return self.suite_builder_result