Changeset 4539

Show
Ignore:
Timestamp:
04/29/08 02:18:00 (3 months ago)
Author:
alberto
Message:

nosetest integration half-done (broken)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • projects/ToscaWidgets/branches/nosetests-integration/setup.cfg

    r4434 r4539  
    11[aliases] 
    22release = egg_info -RDb "" sdist bdist_egg register upload 
     3test = nosetests 
    34 
    45[egg_info] 
     
    1617docformat = reStructuredText 
    1718trac_browser_url = /trac/tw/browser 
     19 
     20[nosetests] 
     21verbosity = 2 
     22with-coverage = false 
     23cover-package = tw 
     24with-toscawidgets = true 
     25exclude-file = tw/mods/tg.py 
     26               tw/mods/pylonshf.py 
     27               tw/core/mako_util.py 
     28with-doctest = true 
     29doctest-extension = txt 
  • projects/ToscaWidgets/branches/nosetests-integration/setup.py

    r4425 r4539  
    7474    author_email=__EMAIL__, 
    7575    license=__LICENSE__, 
    76     test_suite = 'tests', 
    7776    packages = PACKAGES, 
    7877    namespace_packages = ['tw', 'tw.mods'], 
     
    10099    [paste.filter_app_factory] 
    101100    middleware = tw.api:make_middleware 
     101 
     102    [nose.plugins] 
     103    toscawidgets = tw.testutil:TWNosePlugin 
    102104    """, 
    103105    zip_safe=False, 
  • projects/ToscaWidgets/branches/nosetests-integration/tests/__init__.py

    r4535 r4539  
    1 import os 
    2 import pkg_resources 
    3  
    4 import tw.api 
    5 from tw.core.testutil import get_doctest_suite 
    6  
    7 dist_base = pkg_resources.get_distribution('ToscaWidgets').location 
    8  
    9 DOCTEST_FILES = [ 
    10     os.path.join(dist_base, 'docs', '*.txt'), 
    11     os.path.join(dist_base, 'tests', 'test_*.txt'), 
    12     os.path.join(dist_base, 'README.txt'), 
    13     ] 
    14  
    15 DOCTEST_MODULES = [ 
    16     "tw.core.base", 
    17     "tw.core.meta", 
    18     "tw.core.util", 
    19     "tw.core.resources", 
    20     "tw.core.genericfunctions", 
    21     "tw.core.view", 
    22     "tw.core.js", 
    23     ] 
    24  
    25 def additional_tests(): 
    26     return get_doctest_suite(DOCTEST_FILES, DOCTEST_MODULES) 
  • projects/ToscaWidgets/branches/nosetests-integration/tests/test_wsgiapps.py

    r4474 r4539  
    77from tw.core.testutil import RequireMixin 
    88 
    9 examples_dir = os.path.join(pkg_resources.get_distribution('ToscaWidgets').location, 
    10                             'examples') 
     9examples_dir = os.path.join( 
     10    pkg_resources.get_distribution('ToscaWidgets').location, 'examples' 
     11    ) 
    1112sys.path.insert(0, examples_dir) 
    1213 
  • projects/ToscaWidgets/branches/nosetests-integration/tw/core/__init__.py

    r4475 r4539  
     1from pkg_resources import require 
     2require('ToscaWidgets') 
     3del require 
     4 
    15from exceptions import * 
    26from meta import * 
  • projects/ToscaWidgets/branches/nosetests-integration/tw/core/testutil.py

    r4425 r4539  
     1import os 
    12import sys 
    23import doctest 
    3  
    44from new import instancemethod 
    55from glob import glob 
    66from unittest import TestCase 
    77from itertools import imap, chain 
    8 from tw.core.util import install_framework 
    98 
    109import pkg_resources 
     10from nose.plugins import Plugin 
     11 
    1112 
    1213__all__ = [ 
     
    4243    widget_kw = {} 
    4344    def setUp(self): 
    44         install_framework(force=True) 
    4545        if hasattr(self, 'TestWidget'): 
    4646            self.widget = self.TestWidget('test', **self.widget_kw) 
     
    132132            pass # Mod has probably no doctests... ignore it 
    133133    return suite 
     134 
     135class TWNosePlugin(Plugin): 
     136    """Makes sure a dummy tw.framework is installed before any test is run""" 
     137     
     138    name = 'toscawidgets' 
     139    enabled = False 
     140    score = 1000 
     141 
     142    def add_options(self, parser, env=os.environ): 
     143        super(TWNosePlugin, self).add_options(parser, env) 
     144        parser.add_option('--exclude-file',  
     145                          dest='exclude', 
     146                          action = 'append', 
     147                          default=[], 
     148                          help="Do not try to import this file") 
     149         
     150    def configure(self, options, conf): 
     151        super(TWNosePlugin, self).configure(options, conf) 
     152        self.exclude = set(*(chain(op.split() for op in options.exclude))) 
     153 
     154    def begin(self): 
     155        if self.enabled: 
     156            from tw.core.util import install_framework 
     157            install_framework(True) 
     158 
     159    def wantFile(self, file): 
     160        relpath = file.replace(os.getcwd(), '').lstrip('/') 
     161        return  relpath.endswith('.py') and relpath not in self.exclude 
  • projects/ToscaWidgets/branches/nosetests-integration/tw/core/util.py

    r4428 r4539  
    260260def install_framework(force=False): 
    261261    import tw 
     262    assert False, tw.__file__ 
    262263    if not hasattr(tw, 'framework') or force: 
    263264        from paste.registry import StackedObjectProxy, Registry