How to use get_factory_name method in Slash

Best Python code snippet using slash

factoring.py

Source:factoring.py Github

copy

Full Screen

...14 "LazyFactory",15 "import_factory",16 "run_factory",17]18def get_factory_name(factory):19 # type: (LazyFactory) -> str20 """21 Get factory name without importing lazy paths.22 .. code:: python23 >>> from objetto.utils.factoring import get_factory_name24 >>> get_factory_name("module.submodule|Class.method")25 'method'26 >>> get_factory_name(int)27 'int'28 :param factory: Factory.29 :type factory: str or function or collections.abc.Callable or None30 :return: Factory name.31 :rtype: str32 """33 if isinstance(factory, string_types):34 return factory.split("|")[-1].split(".")[-1]35 elif factory is None:36 return "None"37 else:38 assert not isinstance(factory, str)39 return factory.__name__40def format_factory(factory, module=None):...

Full Screen

Full Screen

test_utils_factoring.py

Source:test_utils_factoring.py Github

copy

Full Screen

...23 assert format_factory(int) is int24 with pytest.raises(TypeError):25 params = (3,)26 format_factory(*params)27def test_get_factory_name():28 assert get_factory_name("Class.method") == "method"29 assert get_factory_name("function") == "function"30 assert get_factory_name("module.submodule|Class.method") == "method"31 assert get_factory_name("module.submodule|function") == "function"32 assert get_factory_name(None) == "None"33 assert get_factory_name(int) == "int"34 assert get_factory_name(float) == "float"35def test_import_factory():36 from abc import abstractmethod37 from re import match38 assert import_factory("abc|abstractmethod") is abstractmethod39 assert import_factory(None) is None40 assert import_factory(match) is match41def test_run_factory():42 def my_factory(*args, **kwargs):43 assert args == (1, 2, 3)44 assert kwargs == {"a": 1, "b": 2, "c": 3}45 assert bool(run_factory("re|match", (r"^[a-z]+$", "abc"))) is True46 run_factory(my_factory, (1, 2, 3), dict(a=1, b=2, c=3))47if __name__ == "__main__":48 pytest.main()

Full Screen

Full Screen

factoryboyfixture.py

Source:factoryboyfixture.py Github

copy

Full Screen

1import pytest2import sys3import inflection4import factory5def get_factory_name(factory_class):6 """Get factory fixture name by factory."""7 return inflection.underscore(factory_class.__name__)8def _update_session(factory_class, session):9 factory_class._meta.sqlalchemy_session = session10 for attr, value in factory_class._meta.declarations.items():11 if isinstance(value, (factory.SubFactory, factory.RelatedFactory)):12 _update_session(value.get_factory(), session)13 for used_factory in factory_class._used_factories:14 _update_session(used_factory, session)15def make_fixture(uses=[]):16 def decorator(cls):17 def fix_func(db_session):18 _update_session(cls, db_session)19 return cls20 fixture = pytest.fixture(fix_func)21 setattr(sys.modules[cls.__module__], get_factory_name(cls), fixture)22 setattr(cls, '_used_factories', uses)23 return cls...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Slash automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful