Changeset 0e7611b in sasmodels for conftest.py


Ignore:
Timestamp:
Jan 31, 2018 6:03:03 PM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
b3af1c2
Parents:
335271e
Message:

pytest: re-enable referencing on yielded tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • conftest.py

    r335271e r0e7611b  
    4949    """ 
    5050    if collector.istestfunction(obj, name) and is_generator(obj): 
    51         tests = [pytest.Function(name, parent=collector, args=yielded[1:], callobj=yielded[0]) 
    52                  for yielded in obj()] 
     51        tests = [] 
     52        for number, yielded in enumerate(obj()): 
     53            index, call, args = split_yielded_test(yielded, number) 
     54            test = pytest.Function(name+index, collector, args=args, callobj=call) 
     55            tests.append(test) 
    5356        return tests 
    5457 
     58def split_yielded_test(obj, number): 
     59    if not isinstance(obj, (tuple, list)): 
     60        obj = (obj,) 
     61    if not callable(obj[0]): 
     62        index = "['%s']"%obj[0] 
     63        obj = obj[1:] 
     64    else: 
     65        index = "[%d]"%number 
     66    call, args = obj[0], obj[1:] 
     67    return index, call, args 
    5568 
    5669USE_DOCSTRING_AS_DESCRIPTION = True 
Note: See TracChangeset for help on using the changeset viewer.