Python factory.LazyAttribute() Examples

The following are 2 code examples of factory.LazyAttribute(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module factory , or try the search function .
Example #1
Source File: factories.py    From pdfhook with MIT License 5 votes vote down vote up
def lazy(func):
    return factory.LazyAttribute(func) 
Example #2
Source File: factories.py    From MetaCI with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def fake_name(prefix=None):
    """Generate a fake name with a certain prefix. You can push the name_prefix
       from outside of the factory if you have a preference when you instantiate
       the class."""
    return factory.LazyAttribute(
        lambda a: (getattr(a, "name_prefix", None) or prefix or "")
        + factory.Faker("word").generate({})
    )