{"id":21451851,"url":"https://github.com/reity/fountains","last_synced_at":"2025-03-17T02:42:48.626Z","repository":{"id":53570641,"uuid":"256900439","full_name":"reity/fountains","owner":"reity","description":"Python library for generating and concisely specifying reproducible pseudorandom binary data for unit testing.","archived":false,"fork":false,"pushed_at":"2023-08-26T05:46:10.000Z","size":85,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-23T12:30:32.788Z","etag":null,"topics":["pseudorandom-generators","python-library","random-data","random-data-generation","unit-testing","unit-testing-framework","unit-testing-library","unit-tests"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/fountains","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/reity.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-19T02:53:27.000Z","updated_at":"2022-08-05T02:47:17.000Z","dependencies_parsed_at":"2024-11-23T06:46:22.623Z","dependency_job_id":null,"html_url":"https://github.com/reity/fountains","commit_stats":{"total_commits":40,"total_committers":2,"mean_commits":20.0,"dds":"0.025000000000000022","last_synced_commit":"70e265f52cc8d037037f2dd6266c1a3ad2c3ec4a"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reity%2Ffountains","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reity%2Ffountains/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reity%2Ffountains/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reity%2Ffountains/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reity","download_url":"https://codeload.github.com/reity/fountains/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243964662,"owners_count":20375815,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pseudorandom-generators","python-library","random-data","random-data-generation","unit-testing","unit-testing-framework","unit-testing-library","unit-tests"],"created_at":"2024-11-23T04:26:23.583Z","updated_at":"2025-03-17T02:42:48.608Z","avatar_url":"https://github.com/reity.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"=========\nfountains\n=========\n\nPython library for generating and concisely specifying reproducible pseudorandom binary data for unit testing.\n\n|pypi| |readthedocs| |actions| |coveralls|\n\n.. |pypi| image:: https://badge.fury.io/py/fountains.svg\n   :target: https://badge.fury.io/py/fountains\n   :alt: PyPI version and link.\n\n.. |readthedocs| image:: https://readthedocs.org/projects/fountains/badge/?version=latest\n   :target: https://fountains.readthedocs.io/en/latest/?badge=latest\n   :alt: Read the Docs documentation status.\n\n.. |actions| image:: https://github.com/reity/fountains/workflows/lint-test-cover-docs/badge.svg\n   :target: https://github.com/reity/fountains/actions/workflows/lint-test-cover-docs.yml\n   :alt: GitHub Actions status.\n\n.. |coveralls| image:: https://coveralls.io/repos/github/reity/fountains/badge.svg?branch=main\n   :target: https://coveralls.io/github/reity/fountains?branch=main\n   :alt: Coveralls test coverage summary.\n\nPurpose\n-------\nThis library makes it possible to generate pseudorandom binary test data in a reproducible way, as well as to embed concise specifications of correct function behavior on that test data. This enables the construction of functional tests within unit testing suites that fit within one-line definitions but still test a function's behavior against a large number of inputs. More background information about this library's purpose, design, and implementation can be found in a `related article \u003chttps://github.com/reity/article-specifications-for-distinguishing-functions\u003e`__.\n\nInstallation and Usage\n----------------------\nThis library is available as a `package on PyPI \u003chttps://pypi.org/project/fountains\u003e`__:\n\n.. code-block:: bash\n\n    python -m pip install fountains\n\nThe library can be imported in the usual ways:\n\n.. code-block:: python\n\n    import fountains\n    from fountains import fountains\n\nExamples\n^^^^^^^^\n\n.. |fountains| replace:: ``fountains``\n.. _fountains: https://fountains.readthedocs.io/en/2.1.0/_source/fountains.html#fountains.fountains.fountains\n\nAn object of the |fountains|_ class can be used to generate pseudorandom binary test data:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e [bs.hex() for bs in fountains(length=3, limit=4)]\n    ['e3b0c4', 'ce1bc4', '2ed5b5', '781f5a']\n\nSupplying a function as a parameter to a |fountains|_ object makes it possible to generate a concise (but necessarily incomplete) specification for that function's behavior on a stream of pseudorandom inputs:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e add = lambda bs: bytes([(bs[0] + bs[1] + bs[2]) % 256])\n    \u003e\u003e\u003e bits = list(fountains(3, 8, function=add))\n    \u003e\u003e\u003e bits\n    [0, 0, 1, 1, 1, 0, 1, 0]\n\nWhen converted to a hexadecimal string, this specification encodes partial information about four distinct input-output test cases in every character:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from bitlist import bitlist\n    \u003e\u003e\u003e bitlist(bits).hex()\n    '3a' # Partial outputs from eight distinct tests.\n\nSupplying the specification generated in the manner above as an additional parameter makes it possible to test the function's behavior:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e list(fountains(3, 8, function=add, bits='3a'))\n    [True, True, True, True, True, True, True, True]\n\nEach individual boolean value in the above represents the result of an individual test case. A different function might not satisfy the same partial specification:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e mul = lambda bs: bytes([(bs[0] * bs[1] * bs[2]) % 256])\n    \u003e\u003e\u003e list(fountains(3, 8, function=mul, bits='3a'))\n    [True, False, True, True, False, True, False, True]\n\nEach boolean value in the outputs of the last two code blocks above may be a false negative (i.e., ``True`` may mean that the function satisfies the specification only in a portion of its output for the corresponding input) but is *never a false positive signal of incorrect behavior* (i.e., ``False`` indicates the function does not satisfy the specification for the corresponding input-output pair).\n\nDevelopment\n-----------\nAll installation and development dependencies are fully specified in ``pyproject.toml``. The ``project.optional-dependencies`` object is used to `specify optional requirements \u003chttps://peps.python.org/pep-0621\u003e`__ for various development tasks. This makes it possible to specify additional options (such as ``docs``, ``lint``, and so on) when performing installation using `pip \u003chttps://pypi.org/project/pip\u003e`__:\n\n.. code-block:: bash\n\n    python -m pip install .[docs,lint]\n\nDocumentation\n^^^^^^^^^^^^^\nThe documentation can be generated automatically from the source files using `Sphinx \u003chttps://www.sphinx-doc.org\u003e`__:\n\n.. code-block:: bash\n\n    python -m pip install .[docs]\n    cd docs\n    sphinx-apidoc -f -E --templatedir=_templates -o _source .. \u0026\u0026 make html\n\nTesting and Conventions\n^^^^^^^^^^^^^^^^^^^^^^^\nAll unit tests are executed and their coverage is measured when using `pytest \u003chttps://docs.pytest.org\u003e`__ (see the ``pyproject.toml`` file for configuration details):\n\n.. code-block:: bash\n\n    python -m pip install .[test]\n    python -m pytest\n\nAlternatively, all unit tests are included in the module itself and can be executed using `doctest \u003chttps://docs.python.org/3/library/doctest.html\u003e`__:\n\n.. code-block:: bash\n\n    python src/fountains/fountains.py -v\n\nStyle conventions are enforced using `Pylint \u003chttps://pylint.readthedocs.io\u003e`__:\n\n.. code-block:: bash\n\n    python -m pip install .[lint]\n    python -m pylint src/fountains\n\nContributions\n^^^^^^^^^^^^^\nIn order to contribute to the source code, open an issue or submit a pull request on the `GitHub page \u003chttps://github.com/reity/fountains\u003e`__ for this library.\n\nVersioning\n^^^^^^^^^^\nBeginning with version 0.2.0, the version number format for this library and the changes to the library associated with version number increments conform with `Semantic Versioning 2.0.0 \u003chttps://semver.org/#semantic-versioning-200\u003e`__.\n\nPublishing\n^^^^^^^^^^\nThis library can be published as a `package on PyPI \u003chttps://pypi.org/project/fountains\u003e`__ by a package maintainer. First, install the dependencies required for packaging and publishing:\n\n.. code-block:: bash\n\n    python -m pip install .[publish]\n\nEnsure that the correct version number appears in ``pyproject.toml``, and that any links in this README document to the Read the Docs documentation of this package (or its dependencies) have appropriate version numbers. Also ensure that the Read the Docs project for this library has an `automation rule \u003chttps://docs.readthedocs.io/en/stable/automation-rules.html\u003e`__ that activates and sets as the default all tagged versions. Create and push a tag for this version (replacing ``?.?.?`` with the version number):\n\n.. code-block:: bash\n\n    git tag ?.?.?\n    git push origin ?.?.?\n\nRemove any old build/distribution files. Then, package the source into a distribution archive:\n\n.. code-block:: bash\n\n    rm -rf build dist src/*.egg-info\n    python -m build --sdist --wheel .\n\nFinally, upload the package distribution archive to `PyPI \u003chttps://pypi.org\u003e`__:\n\n.. code-block:: bash\n\n    python -m twine upload dist/*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freity%2Ffountains","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freity%2Ffountains","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freity%2Ffountains/lists"}