Skip to content

Commit

Permalink
Merge document-test-class-names-7032: Document the recommended naming of
Browse files Browse the repository at this point in the history
test classes in Twisted.

Author: eeshangarg
Reviewers: khorn
Fixes: twisted#7032

Add some documentation to the Testing Standard which specifies the correct
way of naming test classes.

git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/trunk@43075 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
  • Loading branch information
khorn committed Sep 14, 2014
1 parent cf007f3 commit 800f5d5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions docs/core/development/policy/test-standard.rst
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,29 @@ tests.



Naming Test Classes
~~~~~~~~~~~~~~~~~~~



When writing tests for the Twisted test suite, test classes are named
``FooTests``, where ``Foo`` is the name of the component being tested.
Here is an example:





.. code-block:: python
class SSHClientTests(unittest.TestCase):
def test_sshClient(self):
foo() # the actual test
Real I/O
~~~~~~~~
Expand Down Expand Up @@ -284,7 +307,7 @@ inside a conditional which looks for the necessary prerequisites:

.. code-block:: python
class SSHClientTests(unittest.TestCase):
def test_sshClient(self):
if not ssh_path:
Expand Down Expand Up @@ -318,14 +341,14 @@ manipulating the class attributes after they've been defined):
.. code-block:: python
class MyTestCase(unittest.TestCase):
class MyTests(unittest.TestCase):
def test_one(self):
...
def test_thing(self):
dotest()
if not haveThing:
MyTestCase.test_thing.im_func.skip = "cannot test without Thing"
MyTests.test_thing.im_func.skip = "cannot test without Thing"
# but test_one() will still run
Expand All @@ -343,12 +366,12 @@ be run.
.. code-block:: python
class TCPTestCase(unittest.TestCase):
class TCPTests(unittest.TestCase):
...
class SSLTestCase(unittest.TestCase):
class SSLTests(unittest.TestCase):
if not haveSSL:
skip = "cannot test without SSL support"
# but TCPTestCase will still run
# but TCPTests will still run
...
Expand Down
Empty file added twisted/topfiles/7032.misc
Empty file.

0 comments on commit 800f5d5

Please sign in to comment.