MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / setup_test_classes

Function setup_test_classes

lib/sqlalchemy/testing/plugin/pytestplugin.py:270–315  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

268 yield inst_or_fn
269
270 def setup_test_classes():
271 for test_class in test_classes:
272 # transfer legacy __backend__ and __sparse_backend__ symbols
273 # to be markers
274 if getattr(test_class.cls, "__backend__", False) or getattr(
275 test_class.cls, "__only_on__", False
276 ):
277 add_markers = {"backend"}
278 elif getattr(test_class.cls, "__sparse_backend__", False):
279 add_markers = {"sparse_backend", "backend"}
280 elif getattr(test_class.cls, "__sparse_driver_backend__", False):
281 add_markers = {"sparse_driver_backend", "backend"}
282 else:
283 add_markers = frozenset()
284
285 existing_markers = {
286 mark.name for mark in test_class.iter_markers()
287 }
288 add_markers = add_markers - existing_markers
289 all_markers = existing_markers.union(add_markers)
290
291 for marker in add_markers:
292 test_class.add_marker(marker)
293
294 sub_tests = list(
295 plugin_base.generate_sub_tests(
296 test_class.cls, test_class.module, all_markers
297 )
298 )
299 if not sub_tests:
300 rebuilt_items[test_class.cls]
301
302 for sub_cls in sub_tests:
303 if sub_cls is not test_class.cls:
304 per_cls_dict = rebuilt_items[test_class.cls]
305
306 module = test_class.getparent(pytest.Module)
307
308 new_cls = pytest.Class.from_parent(
309 name=sub_cls.__name__, parent=module
310 )
311 for marker in add_markers:
312 new_cls.add_marker(marker)
313
314 for fn in collect(new_cls):
315 per_cls_dict[fn.name].append(fn)
316
317 # class requirements will sometimes need to access the DB to check
318 # capabilities, so need to do this for async

Callers

nothing calls this directly

Calls 3

collectFunction · 0.85
unionMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected