def fixture_decorator(callable_): # Decorators act on *functions*, so we need to take care when dynamically # decorating class attributes (which are (un)bound methods). function = inspection.get_function(callable_) # record the fixture type and id for this function function._fixture_type = fixture_type if function.__name__ in DEPRECATED_FIXTURE_TYPE_MAP: # we push deprecated setUps/tearDowns to the beginning or end of # our fixture lists, respectively. this is the best we can do, # because these methods are generated in the order their classes # are created, so we can't assign a fair fixture_id to them. function._fixture_id = 0 if fixture_type.endswith("setup") else float("inf") else: # however, if we've tagged a fixture with our decorators then we # effectively register their place on the class hierarchy by this # fixture_id. function._fixture_id = _fixture_id[0] _fixture_id[0] += 1 return function
def fixture_decorator(callable_): # Decorators act on *functions*, so we need to take care when dynamically # decorating class attributes (which are (un)bound methods). function = inspection.get_function(callable_) # record the fixture type and id for this function function._fixture_type = fixture_type if function.__name__ in DEPRECATED_FIXTURE_TYPE_MAP: # we push deprecated setUps/tearDowns to the beginning or end of # our fixture lists, respectively. this is the best we can do, # because these methods are generated in the order their classes # are created, so we can't assign a fair fixture_id to them. function._fixture_id = 0 if fixture_type.endswith('setup') else float('inf') else: # however, if we've tagged a fixture with our decorators then we # effectively register their place on the class hierarchy by this # fixture_id. function._fixture_id = _fixture_id[0] _fixture_id[0] += 1 return function