Merge pull request #5145 from blueyed/prefer-fast-wrapper
conftest: use a hookwrapper with sorting faster tests first
This commit is contained in:
		
						commit
						322d686ab4
					
				| 
						 | 
					@ -1,5 +1,13 @@
 | 
				
			||||||
 | 
					import pytest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@pytest.hookimpl(hookwrapper=True, tryfirst=True)
 | 
				
			||||||
def pytest_collection_modifyitems(config, items):
 | 
					def pytest_collection_modifyitems(config, items):
 | 
				
			||||||
    """Prefer faster tests."""
 | 
					    """Prefer faster tests.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Use a hookwrapper to do this in the beginning, so e.g. --ff still works
 | 
				
			||||||
 | 
					    correctly.
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
    fast_items = []
 | 
					    fast_items = []
 | 
				
			||||||
    slow_items = []
 | 
					    slow_items = []
 | 
				
			||||||
    neutral_items = []
 | 
					    neutral_items = []
 | 
				
			||||||
| 
						 | 
					@ -24,3 +32,5 @@ def pytest_collection_modifyitems(config, items):
 | 
				
			||||||
                    fast_items.append(item)
 | 
					                    fast_items.append(item)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    items[:] = fast_items + neutral_items + slow_items
 | 
					    items[:] = fast_items + neutral_items + slow_items
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    yield
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue