+# Make the test results available to fixtures
+@pytest.hookimpl(tryfirst=True, hookwrapper=True)
+def pytest_runtest_makereport(item, call):
+ other_hooks = yield
+ report = other_hooks.get_result()
+ bup = item.__dict__.setdefault('bup', {})
+ bup[report.when + '-report'] = report # setup, call, teardown
+ item.bup = bup
+
+def bup_test_sort_order(item):
+ # Pull some slower tests forward to speed parallel runs
+ if item.fspath.basename in ('test_get.py', 'test-index.sh'):
+ return (0, str(item.fspath))
+ return (1, str(item.fspath))
+
+def pytest_collection_modifyitems(session, config, items):
+ items.sort(key=bup_test_sort_order)
+
+@pytest.fixture(autouse=True)
+def no_lingering_errors():
+ def fail_if_errors():
+ if helpers.saved_errors:
+ bt = extract_stack()
+ src_file, src_line, src_func, src_txt = bt[-4]
+ msg = 'saved_errors ' + repr(helpers.saved_errors)
+ assert False, '%s:%-4d %s' % (basename(src_file),
+ src_line, msg)
+
+ fail_if_errors()
+ helpers.clear_errors()
+ yield None
+ fail_if_errors()
+ helpers.clear_errors()
+