Faker is a Python package that generates fake data for you.

Overview

Faker is a Python package that generates fake data for you. Whether you need to bootstrap your database, create good-looking XML documents, fill-in your persistence to stress test it, or anonymize data taken from a production service, Faker is for you.

Faker is heavily inspired by PHP Faker, Perl Faker, and by Ruby Faker.


_|_|_|_|          _|
_|        _|_|_|  _|  _|      _|_|    _|  _|_|
_|_|_|  _|    _|  _|_|      _|_|_|_|  _|_|
_|      _|    _|  _|  _|    _|        _|
_|        _|_|_|  _|    _|    _|_|_|  _|

Latest version released on PyPI Build status of the master branch on Mac/Linux Build status of the master branch on Windows Test coverage Package license


Compatibility

Starting from version 4.0.0, Faker dropped support for Python 2 and from version 5.0.0 only supports Python 3.6 and above. If you still need Python 2 compatibility, please install version 3.0.1 in the meantime, and please consider updating your codebase to support Python 3 so you can enjoy the latest features Faker has to offer. Please see the extended docs for more details, especially if you are upgrading from version 2.0.4 and below as there might be breaking changes.

This package was also previously called fake-factory which was already deprecated by the end of 2016, and much has changed since then, so please ensure that your project and its dependencies do not depend on the old package.

Basic Usage

Install with pip:

pip install Faker

Use faker.Faker() to create and initialize a faker generator, which can generate data by accessing properties named after the type of data you want.

from faker import Faker
fake = Faker()

fake.name()
# 'Lucy Cechtelar'

fake.address()
# '426 Jordy Lodge
#  Cartwrightshire, SC 88120-6700'

fake.text()
# 'Sint velit eveniet. Rerum atque repellat voluptatem quia rerum. Numquam excepturi
#  beatae sint laudantium consequatur. Magni occaecati itaque sint et sit tempore. Nesciunt
#  amet quidem. Iusto deleniti cum autem ad quia aperiam.
#  A consectetur quos aliquam. In iste aliquid et aut similique suscipit. Consequatur qui
#  quaerat iste minus hic expedita. Consequuntur error magni et laboriosam. Aut aspernatur
#  voluptatem sit aliquam. Dolores voluptatum est.
#  Aut molestias et maxime. Fugit autem facilis quos vero. Eius quibusdam possimus est.
#  Ea quaerat et quisquam. Deleniti sunt quam. Adipisci consequatur id in occaecati.
#  Et sint et. Ut ducimus quod nemo ab voluptatum.'

Each call to method fake.name() yields a different (random) result. This is because faker forwards faker.Generator.method_name() calls to faker.Generator.format(method_name).

for _ in range(10):
  print(fake.name())

# 'Adaline Reichel'
# 'Dr. Santa Prosacco DVM'
# 'Noemy Vandervort V'
# 'Lexi O'Conner'
# 'Gracie Weber'
# 'Roscoe Johns'
# 'Emmett Lebsack'
# 'Keegan Thiel'
# 'Wellington Koelpin II'
# 'Ms. Karley Kiehn V'

Pytest fixtures

Faker also has its own pytest plugin which provides a faker fixture you can use in your tests. Please check out the pytest fixture docs to learn more.

Providers

Each of the generator properties (like name, address, and lorem) are called "fake". A faker generator has many of them, packaged in "providers".

from faker import Faker
from faker.providers import internet

fake = Faker()
fake.add_provider(internet)

print(fake.ipv4_private())

Check the extended docs for a list of bundled providers and a list of community providers.

Localization

faker.Faker can take a locale as an argument, to return localized data. If no localized provider is found, the factory falls back to the default en_US locale.

from faker import Faker
fake = Faker('it_IT')
for _ in range(10):
    print(fake.name())

# 'Elda Palumbo'
# 'Pacifico Giordano'
# 'Sig. Avide Guerra'
# 'Yago Amato'
# 'Eustachio Messina'
# 'Dott. Violante Lombardo'
# 'Sig. Alighieri Monti'
# 'Costanzo Costa'
# 'Nazzareno Barbieri'
# 'Max Coppola'

faker.Faker also supports multiple locales. New in v3.0.0.

from faker import Faker
fake = Faker(['it_IT', 'en_US', 'ja_JP'])
for _ in range(10):
    print(fake.name())

# 鈴木 陽一
# Leslie Moreno
# Emma Williams
# 渡辺 裕美子
# Marcantonio Galuppi
# Martha Davis
# Kristen Turner
# 中津川 春香
# Ashley Castillo
# 山田 桃子

You can check available Faker locales in the source code, under the providers package. The localization of Faker is an ongoing process, for which we need your help. Please don't hesitate to create a localized provider for your own locale and submit a Pull Request (PR).

Optimizations

The Faker constructor takes a performance-related argument called use_weighting. It specifies whether to attempt to have the frequency of values match real-world frequencies (e.g. the English name Gary would be much more frequent than the name Lorimer). If use_weighting is False, then all items have an equal chance of being selected, and the selection process is much faster. The default is True.

Command line usage

When installed, you can invoke faker from the command-line:

faker [-h] [--version] [-o output]
      [-l {bg_BG,cs_CZ,...,zh_CN,zh_TW}]
      [-r REPEAT] [-s SEP]
      [-i {package.containing.custom_provider otherpkg.containing.custom_provider}]
      [fake] [fake argument [fake argument ...]]

Where:

  • faker: is the script when installed in your environment, in development you could use python -m faker instead
  • -h, --help: shows a help message
  • --version: shows the program's version number
  • -o FILENAME: redirects the output to the specified filename
  • -l {bg_BG,cs_CZ,...,zh_CN,zh_TW}: allows use of a localized provider
  • -r REPEAT: will generate a specified number of outputs
  • -s SEP: will generate the specified separator after each generated output
  • -i {my.custom_provider other.custom_provider} list of additional custom providers to use. Note that is the import path of the package containing your Provider class, not the custom Provider class itself.
  • fake: is the name of the fake to generate an output for, such as name, address, or text
  • [fake argument ...]: optional arguments to pass to the fake (e.g. the profile fake takes an optional list of comma separated field names as the first argument)

Examples:

$ faker address
968 Bahringer Garden Apt. 722
Kristinaland, NJ 09890

$ faker -l de_DE address
Samira-Niemeier-Allee 56
94812 Biedenkopf

$ faker profile ssn,birthdate
{'ssn': u'628-10-1085', 'birthdate': '2008-03-29'}

$ faker -r=3 -s=";" name
Willam Kertzmann;
Josiah Maggio;
Gayla Schmitt;

How to create a Provider

from faker import Faker
fake = Faker()

# first, import a similar Provider or use the default one
from faker.providers import BaseProvider

# create new provider class
class MyProvider(BaseProvider):
    def foo(self):
        return 'bar'

# then add new provider to faker instance
fake.add_provider(MyProvider)

# now you can use:
fake.foo()
# 'bar'

How to customize the Lorem Provider

You can provide your own sets of words if you don't want to use the default lorem ipsum one. The following example shows how to do it with a list of words picked from cakeipsum :

from faker import Faker
fake = Faker()

my_word_list = [
'danish','cheesecake','sugar',
'Lollipop','wafer','Gummies',
'sesame','Jelly','beans',
'pie','bar','Ice','oat' ]

fake.sentence()
# 'Expedita at beatae voluptatibus nulla omnis.'

fake.sentence(ext_word_list=my_word_list)
# 'Oat beans oat Lollipop bar cheesecake.'

How to use with Factory Boy

Factory Boy already ships with integration with Faker. Simply use the factory.Faker method of factory_boy:

import factory
from myapp.models import Book

class BookFactory(factory.Factory):
    class Meta:
        model = Book

    title = factory.Faker('sentence', nb_words=4)
    author_name = factory.Faker('name')

Accessing the random instance

The .random property on the generator returns the instance of random.Random used to generate the values:

from faker import Faker
fake = Faker()
fake.random
fake.random.getstate()

By default all generators share the same instance of random.Random, which can be accessed with from faker.generator import random. Using this may be useful for plugins that want to affect all faker instances.

Unique values

Through use of the .unique property on the generator, you can guarantee that any generated values are unique for this specific instance.

from faker import Faker
fake = Faker()
names = [fake.unique.first_name() for i in range(500)]
assert len(set(names)) == len(names)

Calling fake.unique.clear() clears the already seen values. Note, to avoid infinite loops, after a number of attempts to find a unique value, Faker will throw a UniquenessException. Beware of the birthday paradox, collisions are more likely than you'd think.

from faker import Faker

fake = Faker()
for i in range(3):
     # Raises a UniquenessException
     fake.unique.boolean()

In addition, only hashable arguments and return values can be used with .unique.

Seeding the Generator

When using Faker for unit testing, you will often want to generate the same data set. For convenience, the generator also provide a seed() method, which seeds the shared random number generator. Calling the same methods with the same version of faker and seed produces the same results.

from faker import Faker
fake = Faker()
Faker.seed(4321)

print(fake.name())
# 'Margaret Boehm'

Each generator can also be switched to its own instance of random.Random, separate to the shared one, by using the seed_instance() method, which acts the same way. For example:

from faker import Faker
fake = Faker()
fake.seed_instance(4321)

print(fake.name())
# 'Margaret Boehm'

Please note that as we keep updating datasets, results are not guaranteed to be consistent across patch versions. If you hardcode results in your test, make sure you pinned the version of Faker down to the patch number.

If you are using pytest, you can seed the faker fixture by defining a faker_seed fixture. Please check out the pytest fixture docs to learn more.

Tests

Run tests:

$ tox

Write documentation for providers:

$ python -m faker > docs.txt

Contribute

Please see CONTRIBUTING.

License

Faker is released under the MIT License. See the bundled LICENSE file for details.

Credits

Comments
  • Move to 'faker' on Pypi

    Move to 'faker' on Pypi

    Looks like the Faker namespace on Pypi has been abandoned for quite a while: https://pypi.python.org/pypi/Faker

    This project's owner @joke2k should file a request to have the namespace transferred to this project.

    It would reduce confusion between Faker (project name) and fake-factory (how it gets pip installed).

    The pypi team is pretty good about transferring namespaces if they're clearly abandoned (which seems to be the case here).

    opened by jeffwidman 30
  • Reproducibility of results broken between Faker-0.7.18 and (Faker-0.8.0, 0.8.7)

    Reproducibility of results broken between Faker-0.7.18 and (Faker-0.8.0, 0.8.7)

    Faker-0.8.0 and Faker-0.7.18 generate different values when given the same random source.

    Is the deterministic generation a goal of the project or not? I assumed that it is before… because the README specifically says that it's useful for unit testing, which is how I use it.

    opened by sp-1234 23
  • AttributeError: 'module' object has no attribute 'Provider'   on Faker()

    AttributeError: 'module' object has no attribute 'Provider' on Faker()

    When i create a Faker class i got following error:

    ERROR: Failure: AttributeError ('module' object has no attribute 'Provider')
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/nose/loader.py", line 418, in loadTestsFromName
        addr.filename, addr.module)
      File "/usr/local/lib/python2.7/dist-packages/nose/importer.py", line 47, in importFromPath
        return self.importFromDir(dir_path, fqname)
      File "/usr/local/lib/python2.7/dist-packages/nose/importer.py", line 94, in importFromDir
        mod = load_module(part_fqname, fh, filename, desc)
      File "/home/rentapplication/django-rentapplication/rentapplication/tests/test_api/test_sessions.py", line 10, in <module>
        from rentapplication.tests.helpers import ReferrerFactory, LandlordFactory
      File "/home/rentapplication/django-rentapplication/rentapplication/tests/helpers.py", line 35, in <module>
        f = Faker()
      File "/usr/local/lib/python2.7/dist-packages/faker/factory.py", line 38, in create
        prov_cls, lang_found = cls._get_provider_class(prov_name, locale)
      File "/usr/local/lib/python2.7/dist-packages/faker/factory.py", line 49, in _get_provider_class
        provider_class = cls._find_provider_class(provider, locale)
      File "/usr/local/lib/python2.7/dist-packages/faker/factory.py", line 87, in _find_provider_class
        return provider_module.Provider
    AttributeError: 'module' object has no attribute 'Provider'```
    
    opened by aldarund 22
  • Typing [Fixed #1489!]

    Typing [Fixed #1489!]

    What does this change?

    Added type annotation hints to all functions/classes in faker!

    What was wrong

    faker did not include type annotations (issue #1489).

    How this fixes it

    • Added automatic type annotations with monkeytype (https://monkeytype.readthedocs.io/en/latest/) for all files in which it did not throw errors.
    • Manual linter fixes.
    • Manual fixes of missing type annotations or unknown type annotations (e.g. type None). Did a lot of code analysis myself, but would also like to credit @nicarl for his earlier work on type annotations (e.g. in documentory.py and generator.py).
    • mypy compliant (mypy -m faker). Also added mypy -m faker test to tox.ini!
    • flake8 compliant (flake8 faker tests)
    • isort compliant (python3 -m isort --check-only --diff .)
    bump-version:minor hacktoberfest-accepted 
    opened by MarcelRobeer 21
  • 8.7.0: pytest is failing

    8.7.0: pytest is failing

    • Faker version: 8.7.0
    • OS: Linux/x86_64

    Brief summary of the issue goes here.

    Steps to reproduce

    • "python setup.py build"
    • "python setup.py install --root </install/prefix>"
    • "/usr/bin/pytest" wyth PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>
    + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-faker-8.7.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-faker-8.7.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
    + PYTHONDONTWRITEBYTECODE=1
    + /usr/bin/pytest -ra -q --ignore tests/providers/test_ssn.py
    =========================================================================== test session starts ============================================================================
    platform linux -- Python 3.8.9, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
    benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
    rootdir: /home/tkloczko/rpmbuild/BUILD/faker-8.7.0, configfile: setup.cfg
    plugins: Faker-8.7.0, forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, httpbin-1.0.0, xdist-2.2.1, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, freezegun-0.4.2, case-1.5.3, isort-1.3.0, aspectlib-1.5.2, asyncio-0.15.1, toolbox-0.5, xprocess-0.17.1, aiohttp-0.3.0, checkdocs-2.7.0, mock-3.6.1, rerunfailures-9.1.1, requests-mock-1.9.3, cov-2.12.1, pyfakefs-4.5.0, cases-3.6.1, flaky-3.7.0, hypothesis-6.14.0, benchmark-3.4.1
    collected 1117 items / 2 errors / 1115 selected
    
    ================================================================================== ERRORS ==================================================================================
    _____________________________________________________________ ERROR collecting tests/sphinx/test_docstring.py ______________________________________________________________
    ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/faker-8.7.0/tests/sphinx/test_docstring.py'.
    Hint: make sure your test modules/packages have valid Python names.
    Traceback:
    /usr/lib64/python3.8/importlib/__init__.py:127: in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
    tests/sphinx/test_docstring.py:8: in <module>
        from faker.sphinx.docstring import DEFAULT_SAMPLE_SIZE, DEFAULT_SEED, ProviderMethodDocstring, Sample
    E   ModuleNotFoundError: No module named 'faker.sphinx'
    _____________________________________________________________ ERROR collecting tests/sphinx/test_validator.py ______________________________________________________________
    ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/faker-8.7.0/tests/sphinx/test_validator.py'.
    Hint: make sure your test modules/packages have valid Python names.
    Traceback:
    /usr/lib64/python3.8/importlib/__init__.py:127: in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
    tests/sphinx/test_validator.py:6: in <module>
        from faker.sphinx.validator import SampleCodeValidator
    E   ModuleNotFoundError: No module named 'faker.sphinx'
    ========================================================================= short test summary info ==========================================================================
    ERROR tests/sphinx/test_docstring.py
    ERROR tests/sphinx/test_validator.py
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    ============================================================================ 2 errors in 4.31s =============================================================================
    

    pytest is executed with --ignore tests/providers/test_ssn.py because https://github.com/joke2k/faker/issues/1454

    stale 
    opened by kloczek 21
  • Public IP blocks used with ipv4_public encompass reserved address namespaces

    Public IP blocks used with ipv4_public encompass reserved address namespaces

    The ipv4_public faker generates IP addresses from public blocks, excluding private blocks configured in IPV4_PUBLIC_NETS and IPV4_PRIVATE_NET_BLOCKS, however it often results in addresses coming from reserved spaces.

    One example is 192.0.0.145, or in general 192.0.0.0/24 addresses from reserved space, per https://en.wikipedia.org/wiki/Reserved_IP_addresses

    This clashes with many popular libraries checking whether IP is public and routable such as django-ipware.

    Steps to reproduce

    >>> startswith = False
    >>> while not startswith:
    ...   ip = fake.ipv4_public()
    ...   if ip.startswith('192.0.0'):
    ...     startswith = True
    ...     print(ip)
    ...
    192.0.0.145
    

    Expected behavior

    No address starting with 192.0.0 generated

    Actual behavior

    192.0.0.145 comes up often.

    opened by maticomp 19
  • Add support for multiple locale data generation

    Add support for multiple locale data generation

    What does this change

    Faker can now accept multiple locales while retaining the same signature to preserve backward compatibility.

    What was wrong

    Faker can only handle a single locale.

    How this fixes it

    The new Faker proxy class will internally create locale-specific generators as needed, and then proxy calls to the generators that can accommodate the call. Generator selection logic may also be specified via weights.

    Notes

    Needless to say, there will be a performance penalty, and the severity of the penalty depends on:

    • How many locales were specified
    • How many locale-specific generators can handle a certain call
    • If a custom distribution will be used

    Fixes #691, fixes #976, partial solution-ish to #453, related to #230

    opened by malefice 17
  • Not possible to seed uuid4

    Not possible to seed uuid4

    It is not possible to seed the uuid4 property.

    >>> f1 = Faker()
    >>> f1.seed(4321)
    >>> print(f1.uuid4())
    4a6d35db-b61b-49ed-a225-e16bc164f7cc
    
    >>> f2 = Faker()
    >>> f2.seed(4321)
    >>> print(f2.uuid4())
    b5f05be8-2f57-4a52-9b6f-5bcd03125278
    
    

    The solution is pretty much given in: http://stackoverflow.com/questions/41186818/how-to-generate-a-random-uuid-which-is-reproducible-with-a-seed-in-python

    opened by J535D165 16
  • 13.3.5: pytest is failing because it uses no longer maintained `random2` module

    13.3.5: pytest is failing because it uses no longer maintained `random2` module

    • Faker version: 13.3.5
    • OS: Linux x86/64

    Brief summary of the issue

    Looks like pytest is failing because test suite still is using outdated random2 module which was never updated for python 3.x).

    Steps to reproduce

    I'm trying to package your module as an rpm package. So I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

    • python3 -sBm build -w --no-isolation
    • because I'm calling build with --no-isolation I'm using during all processes only locally installed modules
    • install .whl file in </install/prefix>
    • run pytest with PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>

    Expected behavior

    pytest should not fail.

    Actual behavior

    Here is pytest output:

    + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-faker-13.3.5-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-faker-13.3.5-2.fc35.x86_64/usr/lib/python3.8/site-packages
    + /usr/bin/pytest -ra -q
    =========================================================================== test session starts ============================================================================
    platform linux -- Python 3.8.13, pytest-7.1.1, pluggy-1.0.0
    rootdir: /home/tkloczko/rpmbuild/BUILD/faker-13.3.5, configfile: setup.cfg
    plugins: Faker-13.3.5
    collected 1491 items / 1 error
    
    ================================================================================== ERRORS ==================================================================================
    _______________________________________________________________ ERROR collecting tests/providers/test_ssn.py _______________________________________________________________
    ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/faker-13.3.5/tests/providers/test_ssn.py'.
    Hint: make sure your test modules/packages have valid Python names.
    Traceback:
    /usr/lib64/python3.8/importlib/__init__.py:127: in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
    tests/providers/test_ssn.py:11: in <module>
        import random2
    E   ModuleNotFoundError: No module named 'random2'
    ============================================================================= warnings summary =============================================================================
    ../../BUILDROOT/python-faker-13.3.5-2.fc35.x86_64/usr/lib/python3.8/site-packages/faker/providers/person/fr_QC/__init__.py:10
      /home/tkloczko/rpmbuild/BUILDROOT/python-faker-13.3.5-2.fc35.x86_64/usr/lib/python3.8/site-packages/faker/providers/person/fr_QC/__init__.py:10: UserWarning: fr_QC locale is deprecated. Please use fr_CA.
        warnings.warn("fr_QC locale is deprecated. Please use fr_CA.")
    
    -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
    ========================================================================= short test summary info ==========================================================================
    ERROR tests/providers/test_ssn.py
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    ======================================================================= 1 warning, 1 error in 10.95s =======================================================================
    
    help wanted 
    opened by kloczek 15
  • Add a random image provider

    Add a random image provider

    Python Image Library is used under the hood to generate a background and drawing a polygon, while forwarding the color generation to the existing color provider.

    So as not to force a dependency on Pillow for all installs, this provider will not work in absence of this library.

    A polygon shape is chosen because its the easiest drawing method to interface with random coordinates, as opposed to ellipses or alike that constrain input parameters, while still providing easily distinguishable random images, as opposed to random noise bitmaps.

    bump-version:minor hacktoberfest-accepted 
    opened by n1ngu 15
  • text-unidecode is released under the Artistic license

    text-unidecode is released under the Artistic license

    text-unidecode is released under the Artistic license v1.0, which is considered non-free by the FSF (and therefore not compatible with the GPL). I believe this clause is also of concern to commercial users of faker too:

    1. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own.

    Not being able to charge a fee for the software is problematic for those of us who are contractors, for example.

    I realise there aren't really any good alternatives (unidecode is GPL licensed as pointed out in #628 , isounidecode doesn't support Python 3), so would a patch making text-unidecode an optional dependency be acceptable?

    opened by moggers87 15
  • Add localized `Person` providers for Belgium

    Add localized `Person` providers for Belgium

    • Faker version: 15.3.4
    • OS: Windows 11

    Faker Person providers don't support Belgian localization ('nl_BE' and 'fr_BE'; 'de_BE' later perhaps). I suggest putting Belgium on the Faker map, for which I plan drafting a PR.

    Steps to reproduce

    1. define test function
      def names(locale: str | None = None) -> list[str]:
          from faker import Faker
      
          Faker.seed(0)  # to reproduce same results
          fake = Faker(locale)
          return [fake.first_name() for _ in range(10)]
      
    2. verify 'nl_BE' gives same result as default ('en_US'), while e.g. 'nl_NL' returns localized names
      assert names('nl_BE') == names() != names('nl_NL')
      
    3. verify 'fr_BE' is rejected altogether
      try:
          names('fr_BE')
          assert False, "should not be reached"
      except AttributeError:
          pass
      

    Expected behavior

    Localized names should be returned for both 'nl_BE' and 'fr_BE'.

    Actual behavior

    Currently, 'nl_BE' returns default ('en_US') names and 'fr_BE' fails.

    opened by Dutcho 0
  • Fix name_female generates mixed names (#1770)

    Fix name_female generates mixed names (#1770)

    What does this change

    Split formats in person/en_GB into formats_female and formats_male.

    What was wrong

    faker.name_female() and faker.name_male() would previously generate mixed names (both female and male names) when using locale en_GB.

    How this fixes it

    formats_female and formats_male are now defined and will no longer fall back on the general format when calling name_female() or name_male().

    Fixes #1770

    opened by nathanael-e 0
  • Suggestion: Generate Date Time values only for at certain times (e.g. Workdays, Weekends)

    Suggestion: Generate Date Time values only for at certain times (e.g. Workdays, Weekends)

    Hi,

    Using fake.date_time() or fake.date_time_between() return values that are quite unrealistic for certain purposes. For my usecase I would love to have a feature that restrict the returned dates to only working days (mon-fri), maybe even only typical working hours (e.g. 08:00-17:00).

    I could imagine that as an optional parameter in the function call: fake.date_time_between(filter="weekdays")

    Other filters could be "weekend", "monday", "nighttime", "daytime" etc.

    opened by SevHub 1
  • Suggestion: generate valid data for barcode structures

    Suggestion: generate valid data for barcode structures

    • Faker version: 15.3.4
    • OS: Windows

    Suggestion: faker already includes functions to generate simple 1d barcodes (ean8 and ean13) plus a few more. In the barcode world there are many other data structures which would be useful to fake.

    I work professionally with barcodes from a customer pov. and often come across some of these:

    • GS1 structure
    • German Post (premium post)
    • UK Royal Mail datamatrix
    • Swiss QR code
    • vcard structure
    • UPU parcel code

    In principle these are just appearing as "random strings", but the data format has to be in a very specific way. It would be very useful to generate such structures and feed to a barcode generator.

    opened by myicq 1
  • Fix siret and siren generation for fr_FR locale company information

    Fix siret and siren generation for fr_FR locale company information

    Hi !

    This is a new attempt to fix the French SIRET/SIREN generation.

    The correction was first submitted in MR #1465 in 2021 but never merged

    I simply did a rebase from the master branch and I added basic tests

    opened by daamien 0
Releases(v15.3.4)
Owner
Daniele Faraglia
Web-native developer, UK based Self-employed
Daniele Faraglia
create custom test databases that are populated with fake data

About Generate fake but valid data filled databases for test purposes using most popular patterns(AFAIK). Current support is sqlite, mysql, postgresql

Emir Ozer 2.2k Jan 6, 2023
Green is a clean, colorful, fast python test runner.

Green -- A clean, colorful, fast python test runner. Features Clean - Low redundancy in output. Result statistics for each test is vertically aligned.

Nathan Stocks 756 Dec 22, 2022
Scalable user load testing tool written in Python

Locust Locust is an easy to use, scriptable and scalable performance testing tool. You define the behaviour of your users in regular Python code, inst

Locust.io 20.4k Jan 8, 2023
A cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard.

PyAutoGUI PyAutoGUI is a cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard. pip inst

Al Sweigart 7.6k Jan 1, 2023
splinter - python test framework for web applications

splinter - python tool for testing web applications splinter is an open source tool for testing web applications using Python. It lets you automate br

Cobra Team 2.6k Dec 27, 2022
Let your Python tests travel through time

FreezeGun: Let your Python tests travel through time FreezeGun is a library that allows your Python tests to travel through time by mocking the dateti

Steve Pulec 3.5k Jan 9, 2023
HTTP client mocking tool for Python - inspired by Fakeweb for Ruby

HTTPretty 1.0.5 HTTP Client mocking tool for Python created by Gabriel Falcão . It provides a full fake TCP socket module. Inspired by FakeWeb Github

Gabriel Falcão 2k Jan 6, 2023
A utility for mocking out the Python Requests library.

Responses A utility library for mocking out the requests Python library. Note Responses requires Python 2.7 or newer, and requests >= 2.0 Installing p

Sentry 3.8k Jan 2, 2023
A test fixtures replacement for Python

factory_boy factory_boy is a fixtures replacement based on thoughtbot's factory_bot. As a fixtures replacement tool, it aims to replace static, hard t

FactoryBoy project 3k Jan 5, 2023
Mixer -- Is a fixtures replacement. Supported Django, Flask, SqlAlchemy and custom python objects.

The Mixer is a helper to generate instances of Django or SQLAlchemy models. It's useful for testing and fixture replacement. Fast and convenient test-

Kirill Klenov 871 Dec 25, 2022
Coroutine-based concurrency library for Python

gevent Read the documentation online at http://www.gevent.org. Post issues on the bug tracker, discuss and ask open ended questions on the mailing lis

gevent 5.9k Dec 28, 2022
Radically simplified static file serving for Python web apps

WhiteNoise Radically simplified static file serving for Python web apps With a couple of lines of config WhiteNoise allows your web app to serve its o

Dave Evans 2.1k Jan 8, 2023
livereload server in python (MAINTAINERS NEEDED)

LiveReload Reload webpages on changes, without hitting refresh in your browser. Installation python-livereload is for web developers who know Python,

Hsiaoming Yang 977 Dec 14, 2022
A screamingly fast Python 2/3 WSGI server written in C.

bjoern: Fast And Ultra-Lightweight HTTP/1.1 WSGI Server A screamingly fast, ultra-lightweight WSGI server for CPython 2 and CPython 3, written in C us

Jonas Haag 2.9k Dec 21, 2022
Waitress - A WSGI server for Python 2 and 3

Waitress Waitress is a production-quality pure-Python WSGI server with very acceptable performance. It has no dependencies except ones which live in t

Pylons Project 1.2k Dec 30, 2022
Python HTTP Server

Python HTTP Server Preview Languange and Code Editor: How to run? Download the zip first. Open the http.py and wait 1-2 seconds. You will see __pycach

SonLyte 16 Oct 21, 2021
PyQaver is a PHP like WebServer for Python.

PyQaver is a PHP like WebServer for Python.

Dev Bash 7 Apr 25, 2022
Robyn is an async Python backend server with a runtime written in Rust, btw.

Robyn is an async Python backend server with a runtime written in Rust, btw. Python server running on top of of Rust Async RunTime. Installation

Sanskar Jethi 1.8k Dec 30, 2022
Faker is a Python package that generates fake data for you.

Faker is a Python package that generates fake data for you. Whether you need to bootstrap your database, create good-looking XML documents, fill-in yo

Daniele Faraglia 15.2k Jan 1, 2023
Faker is a Python package that generates fake data for you.

Faker is a Python package that generates fake data for you. Whether you need to bootstrap your database, create good-looking XML documents, fill-in yo

Daniele Faraglia 15.2k Jan 1, 2023