{ "info": { "author": "Adomas Paltanavicius", "author_email": "adomas.paltanavicius@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Framework :: Django", "License :: OSI Approved :: MIT License", "Topic :: Software Development :: Testing" ], "description": "-----\nAbout\n-----\n\n**homophony** provides ``zc.testbrowser`` integration for Django;\n``zc.testbrowser`` is a lot more robust than the default functional testing\nclient that comes with Django.\n\nSee the introduction_ to ``zc.testbrowser`` for a better understanding\nof how powerful it is.\n\n.. _introduction: http://pypi.python.org/pypi/zc.testbrowser/1.0a1\n\n\n---------------\nUsing homophony\n---------------\n\nFirst of all, you need to have **homophony** installed; for your convenience,\nrecent versions should be available from PyPI.\n\nLet's say you're working on an application called ``foobar``; the tests for\nthis application are located in ``foobar/tests.py``.\n\n\nUnit tests\n==========\n\nUse this as a starting point for ``foobar/tests.py``::\n\n from homophony import BrowserTestCase, Browser\n\n class FoobarTestCase(BrowserTestCase):\n\n def testHome(self):\n browser = Browser()\n browser.open('http://testserver')\n browser.getControl(name='first_name').value = 'Jim'\n browser.getForm().submit()\n self.assertEquals(browser.url, 'http://testserver/hello')\n self.assertEquals(browser.title, 'Hello Jim')\n\n\nBear in mind that implementing custom ``setUp`` and ``tearDown`` methods\nshould involve calling those defined in ``BrowserTestCase``.\n\n\nDoctests\n========\n\nIf you prefer doctests over unit tests (as we do!), use the following as a base\nfor ``foobar/tests.py``::\n\n from homophony import DocFileSuite\n\n def suite():\n return DocFileSuite('tests.txt')\n\n\nAnd here is an example ``foobar/tests.txt`` file::\n\n The website welcomes its visitors with a form:\n\n >>> browser = Browser()\n >>> browser.open('http://testserver')\n >>> browser.getControl(name='first_name').value = 'Jim'\n >>> browser.getForm().submit()\n\n When a name is given, it echoes back with an informal greeting:\n\n >>> browser.title\n 'Hello Jim'\n >>> print browser.contents\n \n ...\n