예제 #1
0
def get_faker(providers, locale=None):
    providers = [("faker.providers.%s" % provider if ("." not in provider) else provider) for provider in providers]
    locale = locale or (random.choice(["en_US"] + list(find_available_locales(providers))))
    fake = faker.Factory.create(locale=locale)
    fake.locale = locale
    fake.locale_language = fake.locale.split("_")[0]
    return fake
예제 #2
0
def get_faker(providers, locale="en"):
    providers = [("faker.providers.%s" % provider if ("." not in provider) else provider) for provider in providers]
    locale = locale or (random.choice(["en_US"] + list(find_available_locales(providers))))
    fake = faker.Factory.create(locale=locale)
    fake.locale = locale
    lang_code = fake.locale.split("_")[0]
    fake.locale_language = lang_code
    fake.language = lang_code
    return fake
예제 #3
0
파일: __init__.py 프로젝트: Brobin/faker
    def test_find_available_locales(self):
        from faker.utils.loading import find_available_locales
        from faker.config import DEFAULT_PROVIDERS

        result = find_available_locales(DEFAULT_PROVIDERS)
        self.assertNotEqual(len(result), 0)
예제 #4
0
 def test_find_available_locales(self):
     result = find_available_locales(PROVIDERS)
     assert len(result) != 0
예제 #5
0
 def test_find_available_locales(self):
     result = find_available_locales(PROVIDERS)
     self.assertNotEqual(len(result), 0)
예제 #6
0
파일: __init__.py 프로젝트: yileye/faker
    def test_find_available_locales(self):
        from faker.utils.loading import find_available_locales
        from faker.config import PROVIDERS

        result = find_available_locales(PROVIDERS)
        self.assertNotEqual(len(result), 0)
예제 #7
0
# coding=utf-8
from faker.utils.loading import find_available_locales

DEFAULT_LOCALE = 'en_US'

DEFAULT_PROVIDERS = (
    'address',
    'barcode',
    'color',
    'company',
    'credit_card',
    'currency',
    'date_time',
    'file',
    'internet',
    'job',
    'lorem',
    'misc',
    'person',
    'profile',
    'python',
    'phone_number',
    'ssn',
    'user_agent',
)

AVAILABLE_LOCALES = find_available_locales(DEFAULT_PROVIDERS)
예제 #8
0
# coding=utf-8
from importlib import import_module
from faker.utils.loading import find_available_locales, find_available_providers

DEFAULT_LOCALE = 'en_US'

META_PROVIDERS_MODULES = [
    'faker.providers',
]

PROVIDERS = find_available_providers(
    [import_module(path) for path in META_PROVIDERS_MODULES])

AVAILABLE_LOCALES = find_available_locales(PROVIDERS)
예제 #9
0
 def test_find_available_locales(self):
     result = find_available_locales(PROVIDERS)
     self.assertNotEqual(len(result), 0)