I'm following the instructions from this post 
http://web2py.com/AlterEgo/default/show/260
but cannot get my methods recognized globally.

ERROR MESSAGE:

ERROR: test_suggest_performer (__builtin__.TestSearch)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "applications/myapp/tests/test_search.py", line 24, in
test_suggest_performer
    suggs = suggest_flavors("straw")
NameError: global name 'suggest_flavors' is not defined

TEST FILE:

import unittest

from gluon.globals import Request
db = test_db

execfile("applications/myapp/controllers/search.py", globals())

class TestSearch(unittest.TestCase):
    def setUp(self):
        request = Request()

    def test_suggest_flavors(self):
        suggs = suggest_flavors("straw")
        self.assertEqual(len(suggs), 1)
        self.assertEqual(suggs[0][1], 'Strawberry')

CONTROLLER:

def suggest_flavors(term):
    return []

Reply via email to