Exemple #1
0
    def __len__(self):
        if not self.sets:
            return 0

        returned = 1
        for x in itervalues(self.sets):
            returned *= len(x)
        return returned
Exemple #2
0
    def __len__(self):
        if not self.sets:
            return 0

        returned = 1
        for x in itervalues(self.sets):
            returned *= len(x)
        return returned
Exemple #3
0
def _find_all_parameters(func):
    returned = {}
    stack = [func]
    while stack:
        f = stack.pop()
        stack.extend(f.get_fixtures())
        for param in f.get_parameters():
            if param.id not in returned:
                returned[param.id] = param
    return list(itervalues(returned))
Exemple #4
0
def _find_all_parameters(func):
    params = []
    stack = [func]
    while stack:
        f = stack.pop()
        for subfixture in f.get_fixtures():
            if isinstance(subfixture, GeneratorFixture):
                params.append(subfixture)
                continue
            else:
                stack.append(subfixture)
        params.extend(f.get_parameters())
    return list(itervalues({p.id: p for p in params}))
def test_iter_fixture_variations_parametrized(suite, planned_test):
    """ Test iteration with no fixture parametrization"""
    fixtures = [planned_test.add_fixture(suite.add_fixture())
                for i in range(2)]

    for fixture in fixtures:
        for i in range(2):
            fixture.parametrize()

    # for each fixture, the possible param dicts it can yield (as lists)
    param_dicts_ordered_by_fixture = []
    for fixture in fixtures:
        fixture_param_dicts = []
        param_names = []
        param_value_options = []
        for param_name, options in iteritems(fixture.params):
            param_names.append(param_name)
            param_value_options.append(options)

        for combination in itertools.product(*itervalues(fixture.params)):
            fixture_param_dicts.append(dict(zip(fixture.params, combination)))

        param_dicts_ordered_by_fixture.append(fixture_param_dicts)


    expected = [dict((f.name, {'value': f.value, 'params': param_dict})
                     for f, param_dict in zip(fixtures, dict_combination))
                for dict_combination in itertools.product(*param_dicts_ordered_by_fixture)]

    got = list(planned_test.iter_expected_fixture_variations())

    assert len(expected) == len(got)

    # we can't use sets here, and sorting the two lists is a nightmare in Python 3 since they contain dicts
    for expected_dict in expected:
        got.remove(expected_dict)
    assert not got