{ "info": { "author": "Og Maciel", "author_email": "omaciel@ogmaciel.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Testing", "Topic :: Utilities" ], "description": "pytest-fauxfactory\n==================\n\n.. image:: https://img.shields.io/pypi/v/pytest-fauxfactory.svg\n :target: https://pypi.python.org/pypi/pytest-fauxfactory\n\n.. image:: https://img.shields.io/pypi/l/pytest-fauxfactory.svg\n :target: https://pypi.python.org/pypi/pytest-fauxfactory\n\n.. image:: https://img.shields.io/pypi/pyversions/pytest-fauxfactory.svg\n :target: https://pypi.python.org/pypi/pytest-fauxfactory\n\n.. image:: https://travis-ci.org/omaciel/pytest-fauxfactory.svg?branch=master\n :target: https://travis-ci.org/omaciel/pytest-fauxfactory\n\n---------------\n\n**pytest-fauxfactory** is a **Pytest** plugin that helps you pass random data to your automated tests, leveraging the\npower of `FauxFactory https://github.com/omaciel/fauxfactory`.\n\nFeatures\n--------\n\npytest-fauxfactory let's you create parameterized automated tests, providing:\n\n- Randomically generated strings via **FauxFactory**\n- Allowing you to provide a `callable` method to return the type and number of data items to be used by your tests\n- Allowing you to provide a `generator` method to return the type and number of data items to be used by your tests\n\nInstallation\n------------\n\n\n::\n\n $ pip install pytest-fauxfactory\n\n\nUsage Examples\n--------------\n\n\nGenerating Random Strings: faux_string\n++++++++++++++++++++++++++++++++++++++\nLet's say you need to generate a random string value (identified as **author**) for a test\n\n.. code-block:: python\n\n @pytest.mark.faux_string()\n def test_generate_alpha_strings(author):\n assert author\n\nThe allowed types of strings that can be generated are:\n\n- alpha\n- alphanumeric\n- cjk\n- html\n- latin1\n- numeric\n- utf8\n- punctuation\n\nUsing the `faux_string` mark without any arguments will generate a single random string for your test.\n\n::\n\n test_generate_alpha_strings[faux_string_0] PASSED\n\n\nSuppose you want to generate **4** random **alpha** strings (identified as **book**) for a test:\n\n.. code-block:: python\n\n @pytest.mark.faux_string(4, 'alpha')\n def test_generate_alpha_strings(book):\n assert book.isalpha()\n\n\nYou will then have 4 tests, each with different values:\n\n::\n\n test_generate_alpha_strings[faux_string_0] PASSED\n test_generate_alpha_strings[faux_string_1] PASSED\n test_generate_alpha_strings[faux_string_2] PASSED\n test_generate_alpha_strings[faux_string_3] PASSED\n\nNow, suppose you also want to make sure that all strings have exactly 43 characters:\n\n.. code-block:: python\n\n @pytest.mark.faux_string(4, 'alpha', length=43)\n def test_generate_alpha_strings(value):\n assert len(value) == 43\n\nAdditionally, you can run tests with different string lengths by passing in a list of lengths:\n\n.. code-block:: python\n\n @pytest.mark.faux_string(4, 'alpha', length=[5, 15])\n def test_gen_alpha_string_with_variable_length(value):\n \"\"\"Generate an `alpha` string of length of either 5 or 15.\"\"\"\n assert len(value) == 5 or len(value) == 15\n\nThis will generate 4 new tests\n\n::\n\n tests/test_faux_string.py::test_gen_alpha_string_with_variable_length[faux_string_0] PASSED [ 91%]\n tests/test_faux_string.py::test_gen_alpha_string_with_variable_length[faux_string_1] PASSED [ 92%]\n tests/test_faux_string.py::test_gen_alpha_string_with_variable_length[faux_string_2] PASSED [ 93%]\n tests/test_faux_string.py::test_gen_alpha_string_with_variable_length[faux_string_3] PASSED\n\nSimilarly, you can run tests with different string types by passing in a list of types:\n\n.. code-block:: python\n\n @pytest.mark.faux_string(4, ['alpha', 'alphanumeric'], length=[5, 10])\n def test_gen_alpha_string_with_variable_types(value):\n \"\"\"Generate alpha strings with length 5, alphanumeric with length 10.\"\"\"\n if len(value) == 5:\n assert not contains_number(value)\n else:\n assert contains_number(value)\n\nThis will generate 4 new tests\n\n::\n\n tests/test_faux_string.py::test_gen_alpha_string_with_variable_types[faux_string_0] PASSED [ 96%]\n tests/test_faux_string.py::test_gen_alpha_string_with_variable_types[faux_string_1] PASSED [ 97%]\n tests/test_faux_string.py::test_gen_alpha_string_with_variable_types[faux_string_2] PASSED [ 98%]\n tests/test_faux_string.py::test_gen_alpha_string_with_variable_types[faux_string_3] PASSED\n\n\nUsing Custom Functions: faux_callable\n+++++++++++++++++++++++++++++++++++++\nNow imagine that you have a custom function that generates values of any type instead of the default types used by\n`faux_string`. Using `fauxfactory.gen_integer` for example:\n\n.. code-block:: python\n\n import fauxfactory\n import pytest\n\n @pytest.mark.faux_callable(4, fauxfactory.gen_integer)\n def test_callable_generate_integers(value):\n \"\"\"Test function that return generated integer\"\"\"\n assert isinstance(value, int)\n\n\nThis will generate 4 new tests\n\n::\n\n tests/test_pytest_fauxfactory.py::test_generate_integers[faux_callable_0] PASSED\n tests/test_pytest_fauxfactory.py::test_generate_integers[faux_callable_1] PASSED\n tests/test_pytest_fauxfactory.py::test_generate_integers[faux_callable_2] PASSED\n tests/test_pytest_fauxfactory.py::test_generate_integers[faux_callable_3] PASSED\n\n\nfaux_callable can also transfer arguments to the callable function:\n\n.. code-block:: python\n\n import fauxfactory\n import pytest\n\n @pytest.mark.faux_callable(4, fauxfactory.gen_integer, min_value=0,\n max_value=100)\n def test_callable_generate_integers(value):\n \"\"\"Test function that return generated integer with kwargs\"\"\"\n assert isinstance(value, int)\n assert 0 <= value <= 100\n\nThis will generate 4 new tests\n\n::\n\n tests/test_pytest_fauxfactory.py::test_generate_integers[faux_callable_0] PASSED\n tests/test_pytest_fauxfactory.py::test_generate_integers[faux_callable_1] PASSED\n tests/test_pytest_fauxfactory.py::test_generate_integers[faux_callable_2] PASSED\n tests/test_pytest_fauxfactory.py::test_generate_integers[faux_callable_3] PASSED\n\n\nOf course the generated values can be of any type! For example, let's generate values as a tuple of alpha strings:\n\n.. code-block:: python\n\n import fauxfactory\n import pytest\n\n def generate_alpha_strings(number=1, length=10):\n \"\"\"function that return a tuple of generated alpha string\"\"\"\n return tuple(fauxfactory.gen_alpha(length=length) for _ in range(number))\n\n @pytest.mark.faux_callable(5, generate_alpha_strings, number=3, length=12)\n def test_callable_generate_from_custom_function(value):\n \"\"\"Test generic function that return a tuple of generated strings\"\"\"\n assert isinstance(value, tuple)\n assert len(value) == 3\n # unpack\n location, organization, cv = value\n for str_alpha in (location, organization, cv):\n assert len(str_alpha) == 12\n assert location != organization\n assert location != cv\n\nThis will generate 5 new tests\n\n::\n\n tests/test_pytest_fauxfactory.py::test_generate_from_custom_function[faux_callable_0] PASSED\n tests/test_pytest_fauxfactory.py::test_generate_from_custom_function[faux_callable_1] PASSED\n tests/test_pytest_fauxfactory.py::test_generate_from_custom_function[faux_callable_2] PASSED\n tests/test_pytest_fauxfactory.py::test_generate_from_custom_function[faux_callable_3] PASSED\n tests/test_pytest_fauxfactory.py::test_generate_from_custom_function[faux_callable_4] PASSED\n\n\nLet's now generate values from a custom function that returns a dictionary:\n\n.. code-block:: python\n\n import fauxfactory\n import pytest\n\n def generate_person():\n \"\"\"Generate a random person record.\"\"\"\n return {\n 'name': fauxfactory.gen_alpha(length=12),\n 'age': fauxfactory.gen_integer(min_value=12, max_value=100)\n }\n\n @pytest.mark.faux_callable(3, generate_person)\n def test_callable_generate_person(value):\n \"\"\"Test generic function that return a dict\"\"\"\n assert isinstance(value, dict)\n assert 'name' in value\n assert 'age' in value\n assert len(value['name']) == 12\n assert 12 <= value['age'] <= 100\n\nThis will generate 5 new tests\n\n::\n\n tests/test_pytest_fauxfactory.py::test_generate_person[faux_callable_0] PASSED\n tests/test_pytest_fauxfactory.py::test_generate_person[faux_callable_1] PASSED\n tests/test_pytest_fauxfactory.py::test_generate_person[faux_callable_2] PASSED\n\n\nUsing Generators: faux_generator\n++++++++++++++++++++++++++++++++\nNow instead of using a callable function, we want to generate tests with values\nof any types from a generator function or generator expression.\nFor this purpose we can use the \"faux_generator\" mark:\n\n\n.. code-block:: python\n\n def alpha_strings_generator(items=1, length=10):\n \"\"\"Generate alpha string value at each iteration.\"\"\"\n for _ in range(items):\n yield fauxfactory.gen_alpha(length=length)\n\n\n @pytest.mark.faux_generator(alpha_strings_generator(items=3, length=12))\n def test_generator_alpha_strings(value):\n \"\"\"Test function generator with kwargs.\"\"\"\n assert len(value) == 12\n\nThis will generate 3 new tests\n\n::\n\n tests/test_pytest_fauxfactory.py::test_generator_alpha_strings[faux_generator_0] PASSED\n tests/test_pytest_fauxfactory.py::test_generator_alpha_strings[faux_generator_1] PASSED\n tests/test_pytest_fauxfactory.py::test_generator_alpha_strings[faux_generator_2] PASSED\n\nWe can also use a generator expression:\n\n.. code-block:: python\n\n list_of_integers = [fauxfactory.gen_integer(min_value=0) for _ in range(4)]\n\n\n @pytest.mark.faux_generator(int_val for int_val in list_of_integers)\n def test_generator_expression(value):\n \"\"\"Test generator expression.\"\"\"\n assert isinstance(value, int)\n assert value >= 0\n\nThis will generate 4 tests\n\n::\n\n tests/test_pytest_fauxfactory.py::test_generator_expression[faux_generator_0] PASSED\n tests/test_pytest_fauxfactory.py::test_generator_expression[faux_generator_1] PASSED\n tests/test_pytest_fauxfactory.py::test_generator_expression[faux_generator_2] PASSED\n tests/test_pytest_fauxfactory.py::test_generator_expression[faux_generator_3] PASSED\n\n\nOf course the returned values can be of any type:\n\n\n.. code-block:: python\n\n def foo_generator():\n \"\"\"Returns different values: first, a string 'foo'; second iteration, a\n list of integers.\"\"\"\n yield 'foo'\n yield [1, 2, 3]\n\n\n @pytest.mark.faux_generator(foo_generator())\n def test_generator_foo_generator(value):\n \"\"\"Test diffrent type values.\"\"\"\n if isinstance(value, list):\n assert value == [1, 2, 3]\n else:\n assert value == 'foo'\n\n\nThis will generate 2 tests\n\n::\n\n tests/test_pytest_fauxfactory.py::test_generator_foo_generator[faux_generator_0] PASSED\n tests/test_pytest_fauxfactory.py::test_generator_foo_generator[faux_generator_1] PASSED\n\nWe can also combine all the above generators:\n\n.. code-block:: python\n\n @pytest.mark.faux_generator(\n alpha_strings_generator(items=3, length=12),\n (int_val for int_val in list_of_integers),\n foo_generator()\n )\n def test_generator_combined(value):\n \"\"\"Test combined generators.\"\"\"\n if isinstance(value, list):\n assert value == [1, 2, 3]\n elif isinstance(value, int):\n assert value >= 0\n else:\n assert value.isalpha()\n\nThis will generate 9 tests\n\n::\n\n tests/test_pytest_fauxfactory.py::test_generator_combined[faux_generator_0] PASSED\n tests/test_pytest_fauxfactory.py::test_generator_combined[faux_generator_1] PASSED\n tests/test_pytest_fauxfactory.py::test_generator_combined[faux_generator_2] PASSED\n tests/test_pytest_fauxfactory.py::test_generator_combined[faux_generator_3] PASSED\n tests/test_pytest_fauxfactory.py::test_generator_combined[faux_generator_4] PASSED\n tests/test_pytest_fauxfactory.py::test_generator_combined[faux_generator_5] PASSED\n tests/test_pytest_fauxfactory.py::test_generator_combined[faux_generator_6] PASSED\n tests/test_pytest_fauxfactory.py::test_generator_combined[faux_generator_7] PASSED\n tests/test_pytest_fauxfactory.py::test_generator_combined[faux_generator_8] PASSED\n\n\nDocumentation\n-------------\n\nDocumentation is in the works but we would love to get help from the community!\n\nAuthors\n=======\n\npytest-fauxfactory is written and maintained by Og Maciel and various\ncontributors.\n\nDevelopment Lead\n----------------\n\n- Og Maciel `@omaciel `_\n\nContributors\n------------\n\n- Djebran Lezzoum `@ldjebran https://github.com/ldjebran`_\n- Jacob Callahan `@JacobCallahan https://github.com/JacobCallahan`_\n- Milan Fale\u0161n\u00edk `@mfalesni https://github.com/mfalesni`_\n\n\n.. :changelog:\n\nRelease History\n===============\n\n1.1.0 (2017-12-06)\n------------------\n\n- Renamed `gen_string` mark to `faux_string` with extended capabilities\n- Added new `faux_callable` and `faux_generator` marks\n- Updated README file to include usable examples\n\n1.0.1 (2017-10-18)\n------------------\n\n- First release as a Pytest plugin exposing a `gen_string` mark\n- Tests can be decorated with new mark to generate random strings as parameters\n\n1.0.0 (2015-05-20)\n------------------\n\n- First release.\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/omaciel/pytest-fauxfactory", "keywords": "pytest", "license": "GPLv3", "maintainer": "", "maintainer_email": "", "name": "pytest-fauxfactory", "package_url": "https://pypi.org/project/pytest-fauxfactory/", "platform": "", "project_url": "https://pypi.org/project/pytest-fauxfactory/", "project_urls": { "Homepage": "https://github.com/omaciel/pytest-fauxfactory" }, "release_url": "https://pypi.org/project/pytest-fauxfactory/1.1.1/", "requires_dist": [ "pytest (>=3.2)", "fauxfactory", "coverage; extra == 'dev'", "flake8; extra == 'dev'", "pytest-xdist; extra == 'dev'", "twine; extra == 'dev'", "wheel; extra == 'dev'" ], "requires_python": "", "summary": "Integration of fauxfactory into pytest.", "version": "1.1.1" }, "last_serial": 3395271, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "f5841fee0be504a753018c50da2cba84", "sha256": "79a123519428f7fb76a3c05d5e919b8c08b6e25b9aa2157cfe8da2a70973c77c" }, "downloads": -1, "filename": "pytest-fauxfactory-1.0.tar.gz", "has_sig": false, "md5_digest": "f5841fee0be504a753018c50da2cba84", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1272, "upload_time": "2015-05-20T16:21:33", "url": "https://files.pythonhosted.org/packages/fa/5a/36b72290854334d37d69c3dfb2daca23155a39ebf7e694bc8cc540038ff9/pytest-fauxfactory-1.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "cb4337b86a751182aa899f498192f129", "sha256": "ccef3c5b716f3211bb83de735ef151992156f96798b81c46192ea33b8b2ac4cd" }, "downloads": -1, "filename": "pytest_fauxfactory-1.0.1-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "cb4337b86a751182aa899f498192f129", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 3368, "upload_time": "2017-10-18T21:26:07", "url": "https://files.pythonhosted.org/packages/0a/85/a243efa928198fc2b035fb008dcf24db7a634e90be46db078c8d32c3ee2e/pytest_fauxfactory-1.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8c689e140f69abdd0c5e71cdf6b8e625", "sha256": "03d5b1308997252c6a53ef37af29e69ed3ab2a680222fa9a096f301e2969d8e3" }, "downloads": -1, "filename": "pytest-fauxfactory-1.0.1.tar.gz", "has_sig": true, "md5_digest": "8c689e140f69abdd0c5e71cdf6b8e625", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2392, "upload_time": "2017-10-18T21:26:05", "url": "https://files.pythonhosted.org/packages/b0/f4/06e8e8d3ee98dfe1af7df81accad70e046b1db0dad1b0ff039b1d10a362f/pytest-fauxfactory-1.0.1.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "df580338ece1484275624eae42c1badd", "sha256": "b79e90efd539c1e789e8534715575aee18b5462a8bf8f064a587324de23da0c0" }, "downloads": -1, "filename": "pytest_fauxfactory-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "df580338ece1484275624eae42c1badd", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11454, "upload_time": "2017-12-06T19:34:56", "url": "https://files.pythonhosted.org/packages/e4/67/3fc539913f40e4d9a7281a7f5ccfdd8ffaa947c1beeca82d381182875078/pytest_fauxfactory-1.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c18a0120fbe0e7d906a1b276fe47a5c6", "sha256": "87e058e35322a8a3edb420b94e488c244c257f506a60e471a88d829b90a6ef89" }, "downloads": -1, "filename": "pytest-fauxfactory-1.1.0.tar.gz", "has_sig": false, "md5_digest": "c18a0120fbe0e7d906a1b276fe47a5c6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8311, "upload_time": "2017-12-06T19:34:57", "url": "https://files.pythonhosted.org/packages/90/2d/394f5779e72c683bbc11409facde816afbb5afe5d72cf1325e526eda357d/pytest-fauxfactory-1.1.0.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "518924115fb9058fcace40bf9e506321", "sha256": "e881007523668f0420711970ebb1c6cee034a11d03c538b9f6fa4bd2eac0ac34" }, "downloads": -1, "filename": "pytest_fauxfactory-1.1.1-py3-none-any.whl", "has_sig": true, "md5_digest": "518924115fb9058fcace40bf9e506321", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11518, "upload_time": "2017-12-06T19:57:22", "url": "https://files.pythonhosted.org/packages/d3/2b/f8c14ca814a9f3ca16de53280ae1f4fbfb8d8a1db5318450b29ba8dea326/pytest_fauxfactory-1.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6804af99ea478f3bc056d9756a6d86bd", "sha256": "30dd6883417982b4f42b5fbb02c43fe7fc69ebff14eb3059793a3e07f194b123" }, "downloads": -1, "filename": "pytest-fauxfactory-1.1.1.tar.gz", "has_sig": true, "md5_digest": "6804af99ea478f3bc056d9756a6d86bd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23420, "upload_time": "2017-12-06T19:57:23", "url": "https://files.pythonhosted.org/packages/1b/d8/1d4d8e19597e01ca542fd7af8669189c27511cc58f524d76532d54cdb047/pytest-fauxfactory-1.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "518924115fb9058fcace40bf9e506321", "sha256": "e881007523668f0420711970ebb1c6cee034a11d03c538b9f6fa4bd2eac0ac34" }, "downloads": -1, "filename": "pytest_fauxfactory-1.1.1-py3-none-any.whl", "has_sig": true, "md5_digest": "518924115fb9058fcace40bf9e506321", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11518, "upload_time": "2017-12-06T19:57:22", "url": "https://files.pythonhosted.org/packages/d3/2b/f8c14ca814a9f3ca16de53280ae1f4fbfb8d8a1db5318450b29ba8dea326/pytest_fauxfactory-1.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6804af99ea478f3bc056d9756a6d86bd", "sha256": "30dd6883417982b4f42b5fbb02c43fe7fc69ebff14eb3059793a3e07f194b123" }, "downloads": -1, "filename": "pytest-fauxfactory-1.1.1.tar.gz", "has_sig": true, "md5_digest": "6804af99ea478f3bc056d9756a6d86bd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23420, "upload_time": "2017-12-06T19:57:23", "url": "https://files.pythonhosted.org/packages/1b/d8/1d4d8e19597e01ca542fd7af8669189c27511cc58f524d76532d54cdb047/pytest-fauxfactory-1.1.1.tar.gz" } ] }