view MoinMoin/_tests/ @ 3063:726f96c0f12e

test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Thu, 21 Feb 2008 21:14:57 +0100
parents 388204baf00f
children b24235ec504f
line wrap: on
line source

# -*- coding: utf-8 -*-
    MoinMoin - MoinMoin.module_tested Tests

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

    @copyright: 2003-2004 by Juergen Hermann <>,
                2007 MoinMoin:AlexanderSchremmer
    @license: GNU GPL, see COPYING for details.

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

class TestSimpleStuff:
    """ The simplest MoinMoin test class

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

    See for reference.
    def testSimplest(self):
        """ module_tested: test description...

        Function name MUST start with 'test' to be included in the
        # You can access the current request with self.request. It is
        # injected for you into the test class by moin test framework.
        result = module_tested.some_function(self.request, 'test_value')
        expected = 'expected value'
        assert result == expected

class TestComplexStuff:
    """ 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>'),

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

        Some test needs specific config values, or they will fail.
        self.config = self.TestConfig(defaults=['this option', 'that option'],
                                      another_option='non default value')

    def teardown_class(cls):
        """ 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.
        result = None
        return result