{ "info": { "author": "David Garcia Garzon", "author_email": "voki@canvoki.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "b2btest - Light framework to setup back-to-back test scripts\n============================================================\n\n`Build Status `__\n\nThis package is helpfull to prepare and manage back-to-back tests to get\ncontrol over software you don\u2019t have proper tests yet.\n\nOn one side, it includes ``back2back``, a comand line tool that performs\nback-to-back tests on any software that can be called by command line\nand produces some output files you want to get warned when they get\ndifferent. You can define the set of commands and the outputs to watch\nin a simple YAML file.\n\nOn the other side, it includes comparision functions and\npython-unittests like asserts you can use within your test suites that\nperform similar workflows, keeping the reference outputs in a folder and\nnamed by the testname.\n\nBoth the command line tool and the python libraries, are extendable with\nplugins to get informative diff for several file formats: audio, xml,\ntext, pdf\u2026\n\nWhy back-to-back testing\n------------------------\n\nA Back-to-back tests is a black box tests that just compares that, given\nan input, you have the same output all the time. Unit testing and Test\nDriven Development are a quite more preferable strategy to test a piece\nof software. But often we need to change a piece of software which has\nbeen developed without proper testing. A quick way to get control over\nit is setting up a set of back-to-back tests and then proceeding with\nthe refactoring with a larger level of confidence than having no test at\nall.\n\n**Note of warning:** Don\u2019t feel too confident by being backed by\nback2back tests. It is black-box testing, so it is hard to ensure full\ncoverage. You may be changing a behaviour which is not exercised by the\nb2b test, and not noticing.\n\nEasing the workflow with b2btest\n--------------------------------\n\nWhen b2b tests are hard to run and maintain, they use to get old and\nuseless. This script automates most tedious back2back related task such\nas setting up, verifying results, accepting changes, clearing data\u2026\n\nFeatures: \\* You can put under back2back testing either - the outcomes\n(files) of any shell command line (with pipes and so on), or - any\nserializable data in a ``unittest.TestCase`` method \\* It is\nauto-checked, like most Xunit frameworks \\* It automagically manages the\nexpectation data \\* On failure, it generates handy data to evaluate the\nchanges by providing diffs and keeping failed and expected data for\nreference. \\* Provides a handy command line to accept failed results as\nproper ones. \\* When the test turns green or it is accepted all failure\nrelated data gets cleared. \\* Comparators and diff generators can be\nadded for your own file type. \\* You can set architecture dependant\noutputs for the same test.\n\nHow to install\n--------------\n\nJust use:\n\n.. code:: bash\n\n $ pip install b2btest\n\nIn order to get the by extension diffs:\n\n.. code:: bash\n\n $ pip install b2btest[audio,xml]\n\nDependencies\n------------\n\nB2b for audio files requires the\n`wavefile `__ module: Which\nin turn requires having\n`libsndfile `__ library installed.\n\nFor xml files, it requires `lxml `__ module and both\n`libxml2 `__ and\n`libxslt `__ libraries installed\n\nBack2Back testing in your unittest\n----------------------------------\n\n.. code:: python\n\n import unittest\n import b2btest # Not used but load a new assertion method for TestCase\n import datetime\n\n class MyTest(unittest.TestCase):\n def test_this(self):\n self.assertB2BEqual(\"data\")\n\n def test_that_willallwaysfail(self):\n self.assertB2BEqual(str(datetime.datetime.now()))\n\n if __name__ == '__main__':\n # acceptMode attribute makes the assert accept the results\n # expectation as new\n if '--accept' in sys.argv:\n sys.argv.remove('--accept')\n unittest.TestCase.acceptMode = True\n\n unittest.main()\n\nBack2Back testing of cli programs\n---------------------------------\n\nWhen you are testing back-to-back the output of a command line, you\ndefine a yaml file like this (name it b2bcases.yaml).\n\n.. code:: yaml\n\n #!/usr/bin/env back2back \n\n datapath: \"b2bdata\" # Point it to the directory containing your reference data\n testcases:\n\n HelloWorld:\n command: echo Hello World > output.txt\n outputs:\n - output.txt\n\n AlwaysChanging:\n command: date > output.txt\n outputs:\n - output.txt\n\n Generate1KHzSine:\n command: sox -n /tmp/sine.wav synth 1.0 sine 1000.0\n outputs:\n - /tmp/sine.wav\n\nTo list the available test cases:\n\n.. code:: bash\n\n back2back b2bcases.yaml --list\n\nTo run them:\n\n.. code:: bash\n\n back2back b2bcases.yaml\n\nThe first time you run a test case, it will fail as there is no\nexpectation, you must to check it is valid and accept it. Successive\nfailures means that the behaviour has change. You can accept the new\nresult if the behavioural change is expected.\n\nTo accept a concrete case:\n\n.. code:: bash\n\n back2back b2bcases.yaml --accept HelloWorld\n\nTo accept all failing tests:\n\n.. code:: bash\n\n back2back b2bcases.yaml --acceptall\n\nIf some output depends on the computer architecture or in the platform\n(windows, mac\u2026) use the ``--arch`` and ``--platform`` options when\naccepting. It will generate an independent expectation file for such\narchitecture or platform.\n\n.. code:: bash\n\n back2back b2bcases.yaml --accept HelloWorld --arch\n\nOld inteface\n------------\n\nIf you want to generate the test cases progamaticaly, you still are able\nto use the old python interface. Instead of a yaml file, write python\nscript like this:\n\nJust like in this b2b script does:\n\n.. code:: python\n\n #!/usr/bin/python\n import sys\n from b2btest import runBack2BackProgram\n\n data_path=\"path/to/b2bdata\"\n back2BackTests = [\n (\"myprogram_with_option\",\n \"./myprogram --option input1.wav input2.wav output.wav otheroutput.wav \",\n [\n \"output.wav\",\n \"otheroutput.wav\",\n ]),\n (\"myprogram_with_other_option\",\n \"./myprogram --other-option input1.wav input2.wav output.wav ignoredoutput.wav \",\n [\n \"output.wav\",\n ]),\n ]\n runBack2BackProgram(data_path, sys.argv, back2BackTests)\n\nSave this file as ``back2back.py``, for example, and make it executable.\n\nUse the python script directly with the same command line but without\nthe yaml file.\n\nExtra advices\n-------------\n\nUse continuous integration\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nPut your tests under a continuous integration system such \\* Travis-CI\n\\* BuildBot \\* TestFarm \\* CDash\n\nYou might be lazy passing tests but bots aren\u2019t. Connect your bots to\nyour VCS so they test for every commit.\n\nKeep your expectations up to date\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nIf one b2b test gets red, don\u2019t keep it for long, either accept it or\nroll-back your code. b2b detect changes, but if you are in a change you\nwon\u2019t notice whether a second one happens. If your expectation data is\nbacked by a version control system dare to accept wrong expectation data\nuntil you fix it. But don\u2019t forget.\n\nChange log\n----------\n\n1.3\n~~~\n\n- Avoid larg diffs by telling just the generated file with the failed\n results\n- Fix unicode problems in certain python versions\n- Using older lxml versions for python<3.5\n\n.. _section-1:\n\n1.2\n~~~\n\n- CLI: Fix: only the first output was actually checked\n- Plugin based type sensitive diff\n- Specific diff for XML\n- XML and Audio diffing now are extras\n- \u2018extensions\u2019 key in yaml testcases to associate custom file\n extensions to a diff plugin\n\n.. _section-2:\n\n1.1\n~~~\n\n- Unit test like usage for back-to-back test Python code instead of\n command line programs.\n- New commandline tool ``back2back`` that takes a yaml file with the\n test cases definitions.\n\n.. _section-3:\n\n1.0\n~~~\n\n- First github version\n- (There were previous unpublished versions)\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/vokimon/back2back", "keywords": "", "license": "GNU General Public License v3 or later (GPLv3+)", "maintainer": "", "maintainer_email": "", "name": "b2btest", "package_url": "https://pypi.org/project/b2btest/", "platform": "", "project_url": "https://pypi.org/project/b2btest/", "project_urls": { "Homepage": "https://github.com/vokimon/back2back" }, "release_url": "https://pypi.org/project/b2btest/1.3.1/", "requires_dist": null, "requires_python": "", "summary": "Light framework to setup back-to-back test", "version": "1.3.1" }, "last_serial": 5929664, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "65c659afb23f895bbbdfa443475c153b", "sha256": "e9d64b3b1bb2d4b3375d3ea10e82be867bf783333c321ee2578e09c84d4de00f" }, "downloads": -1, "filename": "b2btest-1.0.tar.gz", "has_sig": false, "md5_digest": "65c659afb23f895bbbdfa443475c153b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7069, "upload_time": "2013-01-02T23:50:27", "url": "https://files.pythonhosted.org/packages/4d/78/b64877eb458e9d2e7bb4b32743730f3078a9ea42ad7e084ea4ad268bfab6/b2btest-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "900f86c58ad4ce4f840fff6fa26f89d6", "sha256": "430c154afa531fc03f47ca8d3e08701a007503cc8129ca7be2c31db1d002f8f8" }, "downloads": -1, "filename": "b2btest-1.1.tar.gz", "has_sig": false, "md5_digest": "900f86c58ad4ce4f840fff6fa26f89d6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10064, "upload_time": "2016-03-12T12:22:19", "url": "https://files.pythonhosted.org/packages/e1/e0/502b473f182d9687b1bbb5288758ecce9450fa6fbacd458c519c425ce292/b2btest-1.1.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "f6f85bdf1c6b294e0a9585d8e8982faa", "sha256": "5ce4a19b3bcaa162ae91c4f08bee7eb726c5d3f9d05afe5b7f99052c3604990a" }, "downloads": -1, "filename": "b2btest-1.2.tar.gz", "has_sig": false, "md5_digest": "f6f85bdf1c6b294e0a9585d8e8982faa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10369, "upload_time": "2016-03-23T09:28:35", "url": "https://files.pythonhosted.org/packages/b1/39/a32a3ae8ca5a5c9b7a67bf6a1463709b206375e2b903c2ba8c93feb75b5b/b2btest-1.2.tar.gz" } ], "1.3": [ { "comment_text": "", "digests": { "md5": "194adf95c418928be78cd6475c5df805", "sha256": "e8a1887672ea30468e6937870ae56a28a90a67e6b17771e6c931ccd350f65c07" }, "downloads": -1, "filename": "b2btest-1.3.tar.gz", "has_sig": false, "md5_digest": "194adf95c418928be78cd6475c5df805", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13760, "upload_time": "2019-10-04T12:21:03", "url": "https://files.pythonhosted.org/packages/bc/e9/808f7ab4c2395d6847e09cbc2d464bc27e7da5ebe98d6dfaca4ae087ff60/b2btest-1.3.tar.gz" } ], "1.3.1": [ { "comment_text": "", "digests": { "md5": "b7c4ef3e2ac2731840c18ec6d89034e9", "sha256": "961aa0ddfb8794581e39edf7eac71530fe03de69bbd4d5db0948958d02a55fab" }, "downloads": -1, "filename": "b2btest-1.3.1.tar.gz", "has_sig": false, "md5_digest": "b7c4ef3e2ac2731840c18ec6d89034e9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18585, "upload_time": "2019-10-04T18:31:36", "url": "https://files.pythonhosted.org/packages/b2/56/e1ae834801c45a6bab770947037d9fea49311c3f6fc02b371505a7d78d47/b2btest-1.3.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b7c4ef3e2ac2731840c18ec6d89034e9", "sha256": "961aa0ddfb8794581e39edf7eac71530fe03de69bbd4d5db0948958d02a55fab" }, "downloads": -1, "filename": "b2btest-1.3.1.tar.gz", "has_sig": false, "md5_digest": "b7c4ef3e2ac2731840c18ec6d89034e9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18585, "upload_time": "2019-10-04T18:31:36", "url": "https://files.pythonhosted.org/packages/b2/56/e1ae834801c45a6bab770947037d9fea49311c3f6fc02b371505a7d78d47/b2btest-1.3.1.tar.gz" } ] }