All Samples(63701) | Call(17) | Derive(59898) | Import(3786)
A class whose instances are single test cases.
By default, the test code itself should be placed in a method named
'runTest'.
If the fixture may be used for many test cases, create as
many test methods as are needed. When instantiating such a TestCase
subclass, specify in the constructor arguments the name of the test method
that the instance is to execute.
Test authors should subclass TestCase for their own tests. Construction
and deconstruction of the test's environment ('fixture') can be
implemented by overriding the 'setUp' and 'tearDown' methods respectively.
If it is necessary to override the __init__ method, the base class
__init__ method must always be called. It is important that subclasses
should not change the signature of their __init__ method, since instances
of the classes are instantiated automatically by parts of the framework
in order to be run.src/b/a/banana-HEAD/examples/calculator/tests.py banana(Download)
#!/usr/bin/env python from unittest import TestCase, TextTestRunner, defaultTestLoader as loader from banana import register_module import scenarios class CalculatorTestCase(TestCase):
src/l/e/LEPL-4.3.2/src/lepl/_example/support.py LEPL(Download)
''' from logging import getLogger from unittest import TestCase from traceback import format_exception_only, format_exc from lepl._test.base import assert_str class Example(TestCase):
src/l/e/LEPL-4.3.2/src/lepl/_example/search_syntax.py LEPL(Download)
http://stackoverflow.com/questions/2364683/what-is-a-good-python-parser-for-a-google-like-search-query ''' from unittest import TestCase from lepl import * class SearchTest(TestCase):
src/w/e/weightless-HEAD/weightless/examples/wordlengthstest.py weightless(Download)
from unittest import TestCase, main from util import autostart """ This code demonstrates the use of generators in Python. It has been life coded on conferences SPA2008, AgileOpen2008 and the Dutch Python day on October 4th, 2008. The implementations below are in order of increasing complexity, the tests are in reverse order!"""
class PythonTest(TestCase):
""" last test on top """
def testWhyAutoStart(self):
firstTry = withoutAutoStart()
try:
firstTry.send('hello')
src/w/e/weightless-HEAD/weightless/examples/callbacksvsgenerator.py weightless(Download)
from unittest import TestCase, main from util import autostart, compose """ This code demonstrated the difficulties with callbacks and showed a simpler implementation with a generator. Most of the value is in the dynamics of writing the code, not in staring at the end-result. If you want to get the full value of it, throw away the code, start with implementing the first test, see how relatively simple the code is, then watch what you need to do in order to let the second test (which breaks the header in two messages) succeed: how complicated the callback based handler becomes. Then proceed to the generatorBasedHTTPHandler() and see how this is a simple lineair piece of code, and how it remains lineair and simple while fixing it for making the second test (with a broken-up heade) succeed. As a third step, the code for joining multiple network buffers into one buffer (readUntilEOL) is extracted into a separate generator, which can only be 'included' if you use @compose.
class CallbackTest(TestCase):
""" the tests are in reverse order """
def testGeneratorWithBrokenUpHeader(self):
result = []
def httphandler(*args):
result.extend(args)
src/l/e/LEPL-4.3.2/src/lepl/offside/_example/pithon.py LEPL(Download)
#@PydevCodeAnalysisIgnore #from logging import basicConfig, DEBUG from unittest import TestCase from lepl import * from lepl._example.support import Example
src/n/u/numscons-0.10.1/tests/examples/ctypesext/tests/test_foo_py.py numscons(Download)
from unittest import TestCase
from numsconstests.scons_fake.ctypesext import foo
class test_ra(TestCase):
def test(self):
foo()
src/p/y/pylive-HEAD/example/i_pylons/i_pylons/tests/__init__.py pylive(Download)
This module initializes the application via ``websetup`` (`paster setup-app`) and provides the base testing objects. """ from unittest import TestCase import os import sys
class TestController(TestCase):
def __init__(self, *args, **kwargs):
wsgiapp = loadapp('config:test.ini', relative_to=conf_dir)
config = wsgiapp.config
pylons.app_globals._push_object(config['pylons.app_globals'])
pylons.config._push_object(config)
src/g/u/gunicorn-0.11.1/examples/frameworks/pylonstest/pylonstest/tests/__init__.py gunicorn(Download)
This module initializes the application via ``websetup`` (`paster setup-app`) and provides the base testing objects. """ from unittest import TestCase from paste.deploy import loadapp from paste.script.appinstall import SetupCommand
class TestController(TestCase):
def __init__(self, *args, **kwargs):
if pylons.test.pylonsapp:
wsgiapp = pylons.test.pylonsapp
else:
wsgiapp = loadapp('config:%s' % config['__file__'])
src/c/o/cogen-0.2.1/examples/cogen-irc/CogenIrcApp/cogenircapp/tests/__init__.py cogen(Download)
""" import os import sys from unittest import TestCase import pkg_resources import paste.fixture
class TestController(TestCase):
def __init__(self, *args, **kwargs):
wsgiapp = loadapp('config:test.ini', relative_to=conf_dir)
self.app = paste.fixture.TestApp(wsgiapp)
TestCase.__init__(self, *args, **kwargs)
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next