Best Python code snippet using lemoncheesecake
conftest.py
Source:conftest.py
...6import pytest7from hamster_gtk.preferences.preferences_dialog import PreferencesDialog8# Data9@pytest.fixture(params=('sqlalchemy',))10def store_parametrized(request):11 """Return a parametrized store value."""12 return request.param13@pytest.fixture(params=(14 datetime.time(0, 0, 0),15 datetime.time(5, 30, 0),16 datetime.time(17, 22, 0),17))18def day_start_parametrized(request):19 """Return a parametrized day_start value."""20 return request.param21@pytest.fixture(params=(0, 1, 30, 60))22def fact_min_delta_parametrized(request):23 """Return a parametrized fact_min_delta value."""24 return request.param25@pytest.fixture(params=(26 # fauxfactory.gen_utf8(),27 # fauxfactory.gen_latin1(),28 fauxfactory.gen_alphanumeric(),29))30def tmpfile_path_parametrized(request, tmpdir):31 """Return a parametrized tmpfile_path value."""32 return tmpdir.mkdir(request.param).join('tmpfile.hamster')33@pytest.fixture(params=(34 'sqlite',35))36def db_engine_parametrized(request):37 """Return a parametrized db_engine value."""38 return request.param39@pytest.fixture(params=(40 # fauxfactory.gen_utf8(),41 # fauxfactory.gen_latin1(),42 fauxfactory.gen_alphanumeric(),43 ':memory:',44))45def db_path_parametrized(request, tmpdir):46 """Return a parametrized db_path value."""47 if not request.param == ':memory:':48 path = tmpdir.mkdir(request.param).join('hamster.file')49 else:50 path = request.param51 return path52@pytest.fixture(params=(0, 1, 30, 60))53def autocomplete_activities_range_parametrized(request):54 """Return a parametrized autocomplete_activities_range value."""55 return request.param56@pytest.fixture(params=(True, False))57def autocomplete_split_activity_parametrized(request):58 """Return a parametrized autocomplete_split_activity value."""59 return request.param60@pytest.fixture61def config_parametrized(request, store_parametrized, day_start_parametrized,62 fact_min_delta_parametrized, tmpfile_path_parametrized, db_engine_parametrized,63 db_path_parametrized, autocomplete_activities_range_parametrized,64 autocomplete_split_activity_parametrized):65 """Return a config fixture with heavily parametrized config values."""66 return {67 'store': store_parametrized,68 'day_start': day_start_parametrized,69 'fact_min_delta': fact_min_delta_parametrized,70 'tmpfile_path': tmpfile_path_parametrized,71 'db_engine': db_engine_parametrized,72 'db_path': db_path_parametrized,73 'autocomplete_activities_range': autocomplete_activities_range_parametrized,74 'autocomplete_split_activity': autocomplete_split_activity_parametrized,75 }...
decorators.py
Source:decorators.py
...9 return response10 response = f(request=request, *args, **kwargs)11 return datatable_instance.process_response(request, response)12 return decorator(datatable_f)13def parametrized(parametrized_class, param_name='parametrized', qs_obj=0):14 def parametrized_f(f, request, *args, **kwargs):15 parametrized_instance = parametrized_class(request.GET, param_name)16 response = parametrized_instance.process_request(request, param_name)17 if response is not None:18 return response19 if qs_obj:20 qs_o = getattr(request, qs_obj, 0)21 if qs_o:22 qs = qs_o.get_queryset()23 qs = parametrized_instance.apply_filters(request, qs, *args,**kwargs)24 qs_o.update_queryset(qs)25 response = f(request=request, *args, **kwargs)26 return parametrized_instance.process_response(request, response)27 return decorator(parametrized_f)...
test_pep585.py
Source:test_pep585.py
1"""2Applies to a large number of types, including many that weren't supported by `typing`.3"""4import types5from _pytest.python import Metafunc6import pytest7def test_issubclass_second_arg_one_parametrized_type(8 parametrized_type, type_parameters9):10 with pytest.raises(TypeError):11 # noinspection PyTypeHints12 issubclass(parametrized_type, parametrized_type[type_parameters])13def test_isinstance_second_arg_parametrized_type(parametrized_type, type_parameters):14 with pytest.raises(TypeError):15 # noinspection PyTypeHints16 issubclass(parametrized_type, parametrized_type[type_parameters])17def test_isinstance_of_genericalias(parametrized_type, type_parameters):18 assert isinstance(parametrized_type[type_parameters], types.GenericAlias)19def test_isinstance_of_nongeneric(parametrized_type, type_parameters):20 assert isinstance(parametrized_type[type_parameters](), parametrized_type)21def test_type(parametrized_type, type_parameters):22 a: parametrized_type[type_parameters] = parametrized_type()23 b: parametrized_type = parametrized_type()24 assert type(a) == type(b)25def pytest_generate_tests(metafunc: Metafunc):26 parametrized_type_fixture = "parametrized_type"27 type_parameters_fixture = "type_parameters"28 parametrized_types = [29 (list, [str]),30 (set, [str]),31 (frozenset, [str]),32 (tuple, [str]),33 (dict, [str, str]),34 ]35 if parametrized_type_fixture in metafunc.fixturenames:36 metafunc.parametrize(37 parametrized_type_fixture,38 [o[0] for o in parametrized_types],39 ids=[str(s[0]) for s in parametrized_types],40 )41 metafunc.parametrize(42 type_parameters_fixture,43 [o[1] for o in parametrized_types],...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!