If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!


  • 0
    web2pyslices  13 years ago
    Hi, I am trying to use this script, but I am having some troubles. 1) I had to comment out line 60 to avoid
    Traceback (most recent call last):
      File "/home/jon/code/web2py_1.99.2/gluon/shell.py", line 206, in run
        execfile(startfile, _env)
      File "testrunner.py", line 60, in 
        current.app.db=db
    AttributeError: 'thread._local' object has no attribute 'app'
    
    It doesn't look (to me) as if current.app.db gets used again in any case. 2. More importantly I can't make doctests work. I have a simple test controller:
    def simple_test():
        '''
    >>> simple_test()
    'hello world'
        '''
        return ('hello world')
    
    I can run it from the 'Edit Application' menu (http://127.0.0.1:8000/admin/default/design/junk) and it runs fine. I can run it via "python -m doctest -v applications/junk/controllers/junk.py" and it works. But if I use the testRunner.py script I get a problem (rather verbose output below). Basically it reads the expected value as running on to the next line (the end of comment line). Any pointers you can give would be appreciated. I do like the approach of running all three of doctests, unit tests and selenium tests in one script. Thanks, Jonathan.
    python web2py.py -S junk -M -R testrunner.py 
    web2py Web Framework
    Created by Massimo Di Pierro, Copyright 2007-2011
    Version 1.99.2 (2011-09-26 06:55:33) stable
    Database drivers available: SQLite3, pymysql
    0  unittest files found.
    3  controller files with possible doctests found.
    0  userinterface testcases found.
    Run doctests
    No unittests
    No external UI tests
    applications/junk/controllers/junk.py
    Doctest: junk.py ... FAIL
    applications/junk/controllers/appadmin.py
    Doctest: appadmin.py ... ok
    applications/junk/controllers/default.py
    Doctest: default.py ... ok
    
    ======================================================================
    FAIL: applications/junk/controllers/junk.py
    Doctest: junk.py
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/usr/lib/python2.7/doctest.py", line 2166, in runTest
        raise self.failureException(self.format_failure(new.getvalue()))
    AssertionError: Failed doctest test for junk.py
      File "applications/junk/controllers/junk.py", line 0
    
    ----------------------------------------------------------------------
    File "applications/junk/controllers/junk.py", line 3, in junk.py
    Failed example:
        simple_test()
    Expected:
        'hello world'
            '''
            return ('hello world')
    Got:
        'hello world'
    
    
    ----------------------------------------------------------------------
    Ran 3 tests in 0.003s
    
    FAILED (failures=1)
    

Commented on:

Based on http://www.web2pyslices.com/slices/take_slice/67

Hosting graciously provided by:
Python Anywhere