Skip to main content

Generates random data for your tests.

Project description

https://travis-ci.org/omaciel/fauxfactory.png?branch=master https://badge.fury.io/py/fauxfactory.png https://pypip.in/d/fauxfactory/badge.png https://coveralls.io/repos/omaciel/fauxfactory/badge.png?branch=master

FauxFactory generates random data for your automated tests easily!

There are times when you’re writing tests for your application when you need to pass random, non-specific data to the areas you are testing. For these scenarios when all you need is a random string, numbers, dates, times, email address, IP, etc, then FauxFactory can help!

Available methods

  • generate_alpha

  • generate_alphanumeric

  • generate_boolean

  • generate_choice

  • generate_cjk

  • generate_date

  • generate_datetime

  • generate_email

  • generate_integer

  • generate_ipaddr

  • generate_iplum

  • generate_latin1

  • generate_mac

  • generate_negative_integer

  • generate_numeric_string

  • generate_positive_integer

  • generate_string

  • generate_time

  • generate_url

  • generate_utf8

  • generate_uuid

Examples

Some examples:

>>> In [0]: from fauxfactory import FauxFactory

>>> In [2]: FauxFactory.generate_alphanumeric()
>>> Out[2]: u'3MVWA'

>>> In [3]: FauxFactory.generate_alphanumeric(length=15)
>>> Out[3]: u'Cxju7QlNhLMSzaV'

>>> In [4]: FauxFactory.generate_cjk()
>>> Out[4]: u'\u7914\u4f5e\u58cb\u63e5\u56ef'

>>> In [5]: FauxFactory.generate_latin1()
>>> Out[5]: u'\xea\xd4\xf2\xfa\xe5'

>>> In [6]: FauxFactory.generate_url()
>>> Out[6]: u'http://test.edu'

>>> In [7]: FauxFactory.generate_url(scheme='https', tlds='io')
>>> Out[7]: u'https://test.io'

>>> In [8]: FauxFactory.generate_ipaddr()
>>> Out[8]: u'42.237.22.59'

>>> In [9]: FauxFactory.generate_datetime()
>>> Out[9]: datetime.datetime(2225, 5, 22, 18, 19, 12, 452661)

>>> In [10]: FauxFactory.generate_uuid()
>>> Out[10]: u'81670150-ed11-4b28-88a0-7f61ba8338c4'

>>> In [11]: FauxFactory.generate_email()
>>> Out[11]: u'lVYREmpx@example.biz'

>>> In [12]: FauxFactory.generate_time()
>>> Out[12]: datetime.time(22, 51, 2, 154172)

>>> In [13]: FauxFactory.generate_choice(['green', 'yellow', 'blue', 'white'])
>>> Out[13]: 'white'

>>> In [14]: FauxFactory.generate_url(subdomain=FauxFactory.generate_alpha())
>>> Out[14]: u'ftp://GtDPI.gov'

>>> In [15]: FauxFactory.generate_iplum()
>>> Out[15]: u'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'

>>> In [16]: FauxFactory.generate_utf8()
>>> Out[16]: u'\U00042a80\U000fb486\U00010c58\U000f2b5e\U00051c5c'

Installation

FauxFactory is available at PyPI, so installing it is as simple as executing:

$ pip install fauxfactory

Or you can download the latest version and install it using setup.py:

$ git clone git@github.com:omaciel/fauxfactory.git
$ cd fauxfactory
$ python setup.py build install

Contribute

  1. Fork the repository on GitHub to start making your changes to the master branch (or branch off of it).

  2. Write a test which shows that the bug was fixed or that the feature works as expected.

  3. Send a pull request and bug the maintainer until it gets merged and published. :) Make sure to add yourself to AUTHORS.

FauxFactory is written and maintained by Og Maciel and various contributors.

Development Lead

Contributors

Release History

0.3.0 (2014-06-15)

  • FauxFactory is now Python 3 compatible

  • Added new method generate_utf8

0.2.1 (2014-05-09)

  • Fixed issue that prevented strings longer than the full length of LOREM_IPSUM_TEXT from being generated (Guthub Issue #16).

0.2.0 (2014-05-08)

  • Added new ‘Lorem Ipsum’ generator.

  • Changed license from LGPL3+ to Apache 2.0

0.1.3 (2014-04-16)

  • Updated character range for CJK generator to avoid generating ‘tofu’ characters.

  • Added Contributors section to README.

  • New documentation (@faustovaz)

Bugfixes:

  • Fixed generate_string function (@faustovaz)

0.1.2 (2014-03-19)

Bugfixes:

  • Generators for email, url and IP should return a unicode string.

0.1.1 (2014-03-17)

  • Fixed formatting of README for better display on Pypi.

0.1.0 (2014-03-17)

  • Initial Release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fauxfactory-0.3.0.tar.gz (22.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page