{ "info": { "author": "makoto kuwata", "author_email": "kwa@kuwata-lab.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.4", "Programming Language :: Python :: 2.5", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.0", "Programming Language :: Python :: 3.1", "Programming Language :: Python :: 3.2", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Testing" ], "description": "==================\r\nPicoTest.py README\r\n==================\r\n\r\nRelease: 0.2.0\r\n\r\n.. contents::\r\n\r\n\r\n\r\nOverview\r\n========\r\n\r\nPicoTest.py is a small but very useful testing library for Python.\r\n\r\n\r\n\r\nBasic Example\r\n=============\r\n\r\nPicoTest.py uses ``with`` statement instead of ``TestCase`` class.\r\n\r\n* Test topc or context is represented by ``with`` statement.\r\n* Test spec is represented by ``@test`` decorator.\r\n\r\nexamples/1_basic_test.py::\r\n\r\n import picotest\r\n test = picotest.new()\r\n\r\n with test(\"assertion example\"):\r\n\r\n @test(\"1+1 should be 2\")\r\n def _(): # 'self' is not required\r\n assert 1+1 == 2\r\n\r\n @test(\"assertion methods of unittest are avaiable\")\r\n def _(self):\r\n self.assertEqual(\"Haruhi\".upper(), \"HARUHI\")\r\n\r\n @test(\"'assertTextEqual()' is available which shows diff of two texts\")\r\n def _(self):\r\n expected = \"Haruhi\\nMikuru\\nYuki\"\r\n actual = \"\\n\".join([\"Haruhi\", \"Mikuru\", \"Yuki\"])\r\n #actual = \"\\n\".join([\"Haruhi\", \"Michiru\", \"Yuki\"])\r\n self.assertTextEqual(expected, actual)\r\n\r\n if __name__ == '__main__':\r\n picotest.main()\r\n\r\n\r\nOutput example (verbose style)::\r\n\r\n $ python examples/1_basic_test.py\r\n * assertion example\r\n - [passed] 1+1 should be 2\r\n - [passed] assertion methods of unittest are avaiable\r\n - [passed] 'assertTextEqual()' is available which shows diff of two texts\r\n ----------------------------------------------------------------------\r\n ## total:3, passed:3, failed:0, error:0, skipped:0, todo:0\r\n\r\n\r\nOutput example (plain style)::\r\n\r\n $ python examples/1_basic_test.py -sp # or -s plain\r\n ...\r\n ## total:3, passed:3, failed:0, error:0, skipped:0, todo:0\r\n\r\n\r\n\r\nTest Structure\r\n==============\r\n\r\nNested test structure is available.\r\nThis makes you to write tests in structured style.\r\n\r\nexamples/2_structure_test.py::\r\n\r\n import picotest\r\n test = picotest.new()\r\n\r\n with test(\"ClassName\"):\r\n\r\n with test(\"#method_name()\"):\r\n\r\n with test(\"when base is not specified...\"):\r\n\r\n @test(\"int('11') should be 11\")\r\n def _():\r\n assert int('11') == 11\r\n\r\n with test(\"when base is specified...\"):\r\n\r\n @test(\"int('11', 16) should be 17\")\r\n def _():\r\n assert int('11', 16) == 17\r\n\r\n @test(\"int('11', 8) should be 9\")\r\n def _():\r\n assert int('11', 8) == 9\r\n\r\n @test(\"int('11', 2) should be 3\")\r\n def _():\r\n assert int('11', 2) == 3\r\n\r\n if __name__ == '__main__':\r\n test.main()\r\n\r\n\r\n\r\nSetup and Teadown Fixture\r\n=========================\r\n\r\nSetup and teardown fixtures are available.\r\nThey are provided by decorators.\r\n\r\n ``@test.before``\r\n\tSame as setUp(). Invoked before each test.\r\n\r\n ``@test.after``\r\n\tSame as tearDown(). Invoked after each test.\r\n\r\n ``@test.before_all``\r\n\tSimilar to setUpClass(). Invoked only once before all tests.\r\n\r\n ``@test.after_all``\r\n\tSimilar to tearDownClass(). Invoked only once after all tests.\r\n\r\nexamples/3_setup_teadown_test.py::\r\n\r\n import os\r\n import picotest\r\n test = picotest.new()\r\n\r\n with test(\"fixtures (setup, teardown) example\"):\r\n PWD = os.getcwd()\r\n\r\n @test.before_all # setupAll\r\n def _():\r\n os.mkdir(\"_sandbox\")\r\n os.chdir(\"_sandbox\")\r\n\r\n @test.after_all # afterAll\r\n def _():\r\n os.chdir(PWD)\r\n os.rmdir(\"_sandbox\")\r\n\r\n @test.before # setup\r\n def _(self):\r\n self.name = \"Haruhi\"\r\n self.team = \"SOS\"\r\n\r\n @test.after # teardown\r\n def _(self):\r\n pass\r\n\r\n @test(\"fixture should be called #1\")\r\n def _(self):\r\n self.assertEqual(\"Haruhi\", self.name)\r\n\r\n @test(\"fixture should be called #2\")\r\n def _(self):\r\n self.assertEqual(\"SOS\", self.team)\r\n\r\n if __name__ == '__main__':\r\n picotest.main()\r\n\r\n\r\n\r\nFixture Injection\r\n=================\r\n\r\nFixture Injection is available which is more flexible than setup/teardown.\r\n\r\nexamples/4_fixture_injection_test.py::\r\n\r\n import os\r\n import picotest\r\n test = picotest.new()\r\n\r\n with test(\"fixture injection example\"):\r\n\r\n @test.fixture\r\n def member(self):\r\n yield \"Haruhi\" # use 'yield', not 'return'\r\n\r\n @test.fixture\r\n def team(): # 'self' is optional\r\n yield \"SOS\"\r\n\r\n @test(\"fixture is injected automatically\")\r\n def _(self, member, team):\r\n assert member == \"Haruhi\"\r\n assert team == \"SOS\"\r\n\r\n @test.fixture\r\n def tmpfile(self):\r\n ## setup temporary file\r\n filename = \"_tmpfile.txt\"\r\n with open(filename, \"w\") as f: f.write(\"SOS\\n\")\r\n yield filename\r\n ## teardown temporary file\r\n os.unlink(filename)\r\n\r\n @test(\"temporary file is created and removed automatically\")\r\n def _(tmpfile):\r\n assert tmpfile == \"_tmpfile.txt\"\r\n with open(tmpfile) as f:\r\n assert f.read() == \"SOS\\n\"\r\n\r\n if __name__ == '__main__':\r\n picotest.main()\r\n\r\n\r\n\r\nSkip and Todo\r\n=============\r\n\r\nPicoTest.py supports test skip and todo.\r\n\r\npicotest.skip_when(condition, reason)\r\n When condition is true then skip rest assertions.\r\n\r\npicotest.todo\r\n Decorator to represents that \"feature is not implemented yet\".\r\n\r\ntest.TODO(description):\r\n Same as::\r\n\r\n @test(\"...description...\")\r\n\t@todo\r\n\tdef _():\r\n\t assert False # expected failure\r\n\r\n\r\nexample/5_skip_and_todo_test.py::\r\n\r\n import picotest\r\n from picotest import skip_when, todo\r\n test = picotest.new()\r\n\r\n with test(\"skip and todo example\"):\r\n\r\n @test(\"skip test when condition is true\")\r\n def _(self):\r\n condition = True\r\n skip_when(condition, \"REASON\")\r\n assert 1 == 0 # unreachable\r\n\r\n @test(\"'@todo' means 'not implemented yet'\")\r\n @todo\r\n def _(self):\r\n assert 1 == 0 # expected failure\r\n\r\n test.TODO(\"something what you have to do #1\")\r\n test.TODO(\"something what you have to do #2\")\r\n\r\n if __name__ == '__main__':\r\n picotest.main()\r\n\r\n\r\n\r\nExtened Assertion Methods\r\n=========================\r\n\r\nPicoTest.py adds some new assertion methods to unittest.TestCase class.\r\n\r\nself.assertTextEqual(expected, actual)\r\n\tSimilar to ``assertEqual()``, but diplays unified diff when actual and\r\n\texpected are different text. Equivarent to ``assertMultilineEqual()``\r\n\tbut available in Python 2.6 or older.\r\n\tExample::\r\n\r\n\t expected = \"Haruhi\\nMikuru\\nYuki\\n\"\r\n\t actual = \"Haruhi\\nMichiru\\nYuki\\n\"\r\n\t self.assertTextEqual(expected, actual)\r\n\t ## output:\r\n\t # AssertionError: texts are not equal.\r\n\t # --- expected\r\n\t # +++ actual\r\n\t # @@ -1,3 +1,3 @@\r\n\t # Haruhi\r\n\t # -Mikuru\r\n\t # +Michiru\r\n\t # Yuki\r\n\r\nself.assertException(function, exceptionclass[, errormsg=None])\r\n\tSimilar to ``assertRaise()``, but this can check error message.\r\n\t``errormsg`` can be string or pattern object compiled by ``re.compile()``.\r\n\tIn addition, you can get exeption object as ``function.exception``.\r\n\tExample::\r\n\r\n\t def fn(): int(\"foo\")\r\n\t self.assertException(fn, ValueError, \"invalid literal for int() with base 10: 'foo'\")\r\n\t ## or\r\n\t self.assertException(fn, ValueError, re.compile(r'^invalid literal'));\r\n\t ## or\r\n\t self.assertException(fn, ValueError)\r\n\t self.assertEqual(\"invalid literal for int() with base 10: 'foo'\", str(fn.exception))\r\n\r\nself.assertNotException(function[, exceptionclass=Exception])\r\n\tConfirms that function doesn't raise exception.\r\n\tExample::\r\n\r\n\t def fn(): int(\"FF\", 16)\r\n\t self.assertNotException(fn)\r\n\r\n\r\n\r\nCommand-line Interface\r\n======================\r\n\r\nPicoTest.py provides command-line interface::\r\n\r\n $ python test/foo_test.py # run test script (verbose style)\r\n $ python test/foo_test.py -sp # run test script (plain style)\r\n $ python test/*.py # run all test scripts\r\n $ python -m picotest test/*.py # run all test scripts\r\n $ python -m picotest test # run all under 'test' directory\r\n $ python -m picotest -h # show help\r\n $ python -m picotest -v # print version\r\n $ python -m picotest -sv test/*.py # or -s verbose\r\n $ python -m picotest -ss test/*.py # or -s simple\r\n $ python -m picotest -sp test/*.py # or -s plain\r\n $ python -m picotest --test='...' test # filter by description\r\n $ python -m picotest -D test/*.py # show all backtrace\r\n\r\n``picotest.main()`` exists process with status code which represens number\r\nof failed or error tests::\r\n\r\n $ python examples/1_basic_test.py -sp\r\n ..f\r\n ----------------------------------------------------------------------\r\n [Failed] assertion example > 'assertTextEqual()' is available which shows diff of two texts\r\n :\r\n ----------------------------------------------------------------------\r\n ## total:3, passed:2, failed:1, error:0, skipped:0, todo:0\r\n $ echo $?\r\n 1 # number of failed or error tests\r\n\r\n\r\n\r\nCopyright\r\n=========\r\n\r\n$Copyright: copyright(c) 2011 kuwata-lab.com all rights reserved $\r\n\r\n\r\n\r\nLicense\r\n=======\r\n\r\n$License: MIT License $", "description_content_type": null, "docs_url": null, "download_url": "http://pypi.python.org/packages/source/P/PicoTest/PicoTest-0.2.0.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/PicoTest", "keywords": "", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "PicoTest", "package_url": "https://pypi.org/project/PicoTest/", "platform": "any", "project_url": "https://pypi.org/project/PicoTest/", "project_urls": { "Download": "http://pypi.python.org/packages/source/P/PicoTest/PicoTest-0.2.0.tar.gz", "Homepage": "http://pypi.python.org/PicoTest" }, "release_url": "https://pypi.org/project/PicoTest/0.2.0/", "requires_dist": null, "requires_python": null, "summary": "a small but very useful testing library for Python", "version": "0.2.0" }, "last_serial": 784909, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "53d805e3f8df99176c9bbdc94d2cdcba", "sha256": "dd105c21bb92372cdde02339e08472b88f42f16cd88557dc0fe58ec0c5dc5287" }, "downloads": -1, "filename": "PicoTest-0.1.0-py2.4.egg", "has_sig": false, "md5_digest": "53d805e3f8df99176c9bbdc94d2cdcba", "packagetype": "bdist_egg", "python_version": "2.4", "requires_python": null, "size": 17673, "upload_time": "2011-11-14T00:20:30", "url": "https://files.pythonhosted.org/packages/4a/21/e9eaa75ef162fb49ec43f1df7526ea0019d3dd5febf7ec7031066509d141/PicoTest-0.1.0-py2.4.egg" }, { "comment_text": "", "digests": { "md5": "81deff7910096f21ec6af21bfddb4a4f", "sha256": "66c441f46da86e67d189d1141075bb769b9c65d6f3b826cf86772adc953a96eb" }, "downloads": -1, "filename": "PicoTest-0.1.0-py3.0.egg", "has_sig": false, "md5_digest": "81deff7910096f21ec6af21bfddb4a4f", "packagetype": "bdist_egg", "python_version": "3.0", "requires_python": null, "size": 17523, "upload_time": "2011-11-14T00:21:06", "url": "https://files.pythonhosted.org/packages/68/39/aa338f45518c4c3fa2bd0bed17692340920c7eadd6c3d1a2d30fccfccd82/PicoTest-0.1.0-py3.0.egg" }, { "comment_text": "", "digests": { "md5": "248f924342f5a16717c8bf52999d9ace", "sha256": "dd446cbcc66c8bdef53520f5f58edf43c9b55b96586f2c9dd92ba17d0eb66a87" }, "downloads": -1, "filename": "PicoTest-0.1.0.tar.gz", "has_sig": false, "md5_digest": "248f924342f5a16717c8bf52999d9ace", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14761, "upload_time": "2011-11-14T00:19:48", "url": "https://files.pythonhosted.org/packages/d8/c1/e480d38468f0e0c756be10558cf327227df98172b2f04ecd09e348144e09/PicoTest-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "6f587f59036bc70b79b838634566bc6b", "sha256": "a54a6639461de6af57a9157d8fcd80ada90a0516aa1a06fbf4061813fb76c448" }, "downloads": -1, "filename": "PicoTest-0.2.0-py2.4.egg", "has_sig": false, "md5_digest": "6f587f59036bc70b79b838634566bc6b", "packagetype": "bdist_egg", "python_version": "2.4", "requires_python": null, "size": 19705, "upload_time": "2011-11-18T14:54:26", "url": "https://files.pythonhosted.org/packages/c9/d6/b5112af20e99f8d0de85a8b27b7c928257a4f0a4b69ccecdb0c2fa874453/PicoTest-0.2.0-py2.4.egg" }, { "comment_text": "", "digests": { "md5": "5ad5f8055c1d25285239f59a0064f860", "sha256": "73532c1d32f879164af2c21317f4846ecc7c95fef11b16dab8d91e89a40ccc3e" }, "downloads": -1, "filename": "PicoTest-0.2.0-py3.0.egg", "has_sig": false, "md5_digest": "5ad5f8055c1d25285239f59a0064f860", "packagetype": "bdist_egg", "python_version": "3.0", "requires_python": null, "size": 19511, "upload_time": "2011-11-18T14:54:40", "url": "https://files.pythonhosted.org/packages/44/f8/318432d1e80f9c2bb2221b7dc9fe5ce0c839ab70f8d7b1edbc9c89a8a749/PicoTest-0.2.0-py3.0.egg" }, { "comment_text": "", "digests": { "md5": "0c04c396ce1ad92d3b98b7735101cc23", "sha256": "4f44311188988bfd6c64d5de53116f5c5a08faa2bd41c327baed8a2cd28adf8d" }, "downloads": -1, "filename": "PicoTest-0.2.0.tar.gz", "has_sig": false, "md5_digest": "0c04c396ce1ad92d3b98b7735101cc23", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17368, "upload_time": "2011-11-18T14:53:01", "url": "https://files.pythonhosted.org/packages/67/06/fea8c3b0a84166de8a8b2c0fd3a2e9ef1df71bfb75b83b943995cf655246/PicoTest-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6f587f59036bc70b79b838634566bc6b", "sha256": "a54a6639461de6af57a9157d8fcd80ada90a0516aa1a06fbf4061813fb76c448" }, "downloads": -1, "filename": "PicoTest-0.2.0-py2.4.egg", "has_sig": false, "md5_digest": "6f587f59036bc70b79b838634566bc6b", "packagetype": "bdist_egg", "python_version": "2.4", "requires_python": null, "size": 19705, "upload_time": "2011-11-18T14:54:26", "url": "https://files.pythonhosted.org/packages/c9/d6/b5112af20e99f8d0de85a8b27b7c928257a4f0a4b69ccecdb0c2fa874453/PicoTest-0.2.0-py2.4.egg" }, { "comment_text": "", "digests": { "md5": "5ad5f8055c1d25285239f59a0064f860", "sha256": "73532c1d32f879164af2c21317f4846ecc7c95fef11b16dab8d91e89a40ccc3e" }, "downloads": -1, "filename": "PicoTest-0.2.0-py3.0.egg", "has_sig": false, "md5_digest": "5ad5f8055c1d25285239f59a0064f860", "packagetype": "bdist_egg", "python_version": "3.0", "requires_python": null, "size": 19511, "upload_time": "2011-11-18T14:54:40", "url": "https://files.pythonhosted.org/packages/44/f8/318432d1e80f9c2bb2221b7dc9fe5ce0c839ab70f8d7b1edbc9c89a8a749/PicoTest-0.2.0-py3.0.egg" }, { "comment_text": "", "digests": { "md5": "0c04c396ce1ad92d3b98b7735101cc23", "sha256": "4f44311188988bfd6c64d5de53116f5c5a08faa2bd41c327baed8a2cd28adf8d" }, "downloads": -1, "filename": "PicoTest-0.2.0.tar.gz", "has_sig": false, "md5_digest": "0c04c396ce1ad92d3b98b7735101cc23", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17368, "upload_time": "2011-11-18T14:53:01", "url": "https://files.pythonhosted.org/packages/67/06/fea8c3b0a84166de8a8b2c0fd3a2e9ef1df71bfb75b83b943995cf655246/PicoTest-0.2.0.tar.gz" } ] }