From 149b4f7e88a3553f0135b96bca379cce5b80c68e Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Tue, 23 Jun 2015 11:16:33 -0300 Subject: [PATCH] Doc review: turn "running tests on nose" section into a unittest section At its core, what's really important to get accross is that an Avocado test is compatible with unittest.TestCase, and it can be run with compatible test runners. Signed-off-by: Cleber Rosa --- docs/source/WritingTests.rst | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/docs/source/WritingTests.rst b/docs/source/WritingTests.rst index 1058eb0a..8b6ca0d3 100644 --- a/docs/source/WritingTests.rst +++ b/docs/source/WritingTests.rst @@ -260,14 +260,13 @@ Executing an Avocado test gives:: INTERRUPT : 0 TIME : 1.00 s -Running tests with nosetests -============================ +Running tests under other :mod:`unittest` runners +------------------------------------------------- + +`nose `__ is another Python testing framework +that is also compatible with :mod:`unittest`. -`nose `__ is a Python testing framework with -similar goals as Avocado, except that avocado also intends to provide tools to -assemble a fully automated test grid, plus richer test API for tests on the -Linux platform. Regardless, the fact that an Avocado class is also an unittest -cass, you can run them with the ``nosetests`` application:: +Because of that, you can run avocado tests with the ``nosetests`` application:: $ nosetests examples/tests/sleeptest.py . @@ -276,6 +275,28 @@ cass, you can run them with the ``nosetests`` application:: OK +Conversely, you can also use the standard :func:`unittest.main` entry point to run an +Avocado test. Check out the following code, to be saved as ``dummy.py``:: + + from avocado import Test + from unittest import main + + class Dummy(Test): + def test(self): + self.assertTrue(True) + + if __name__ == '__main__': + main() + +It can be run by:: + + $ python dummy.py + . + ---------------------------------------------------------------------- + Ran 1 test in 0.000s + + OK + Setup and cleanup methods ========================= -- GitLab