moin-2.0 / build / lib / MoinMoin / _tests / _test_template.py

# Copyright: 2003-2004 by Juergen Hermann <jh@web.de>
# Copyright: 2007 MoinMoin:AlexanderSchremmer
# Copyright: 2009 MoinMoin:ReimarBauer
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.

"""
    MoinMoin - MoinMoin.module_tested Tests

    Module names must start with 'test_' to be included in the tests.
"""


# include here the module that you want to test:
from MoinMoin import module_tested


class TestSimpleStuff(object):
    """ The simplest MoinMoin test class

    Class name must start with 'Test' to be included in
    the tests.

    See http://codespeak.net/py/dist/test.html for reference.
    """
    def testSimplest(self):
        """ module_tested: test description...

        Function name MUST start with 'test' to be included in the
        tests.
        """
        result = module_tested.some_function('test_value')
        expected = 'expected value'
        assert result == expected


class TestComplexStuff(object):
    """ Describe these tests here...

    Some tests may have a list of tests related to this test case. You
    can add a test by adding another line to this list
    """
    _tests = (
        # description,  test,            expected
        ('Line break',  '<<BR>>',        '<br>'),
    )

    from MoinMoin._tests import wikiconfig
    class Config(wikiconfig.Config):
        foo = 'bar'  # we want to have this non-default setting

    def setup_class(self):
        """ Stuff that should be run to init the state of this test class
        """

    def teardown_class(self):
        """ Stuff that should run to clean up the state of this test class
        """

    def testFunction(self):
        """ module_tested: function should... """
        for description, test, expected in self._tests:
            result = self._helper_function(test)
            assert result == expected

    def _helper_fuction(self, test):
        """ Some tests needs extra  work to run

        Keep the test non interesting details out of the way.
        """
        module_tested.do_this()
        module_tested.do_that()
        result = None
        return result
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.