Hello,

Has anyone encountered the following when running nosetest and
sqlalchemy:

ERROR: tests.test_model.TestMe.test_empty
----------------------------------------------------------------------
Traceback (most recent call last):
 File
"/usr/lib/python2.4/site-packages/nose-0.9.0-py2.4.egg/nose/case.py",
line 129, in runTest
   self.testCase(*self.arg)
 File "/home/dax/tmp/tgtest/tgtest/tests/test_model.py", line 30, in
test_empty
   entry = list(Book.select())
 File "build/bdist.linux-i686/egg/sqlalchemy/ext/assignmapper.py",
line 6, in do
 File "build/bdist.linux-i686/egg/sqlalchemy/orm/query.py", line 17,
in __init__
 File "build/bdist.linux-i686/egg/sqlalchemy/orm/mapper.py", line
1444, in class_mapper
InvalidRequestError: Class 'Book' entity name 'None' has no mapper
associated with it

I am using tg 1.0b2


tg-admin quickstart -s -i tgtest


In my model.py I have

from sqlalchemy.ext.assignmapper import assign_mapper

book_table = Table('book', metadata,
   Column('id', Integer, primary_key=True),
   Column('title', String, nullable=False, unique=True)
)

class Book(object):
   pass

assign_mapper(session.context, Book, book_table)


In my test_model.py I have

from sqlalchemy import *
from turbogears import config, redirect, expose, database,
errorhandling
from turbogears.testutil import create_request, capture_log, print_log,
sqlalchemy_cleanup
from turbogears.database import metadata, bind_meta_data, session


from tgtest import model
from tgtest.model import Book

config.update({"sqlalchemy.dburi" : "sqlite:///:memory:"})

bind_meta_data()
metadata.engine.echo = True

class TestMe:
   def setUp(self):
       metadata.create_all()

   def tearDown(self):
       sqlalchemy_cleanup()


   def test_empty(self):
       entry = list(Book.select())
       assert len(entry) is 0


   def test_add(self):
       b = Book()
       b.title = 'Harry Potter and the Half-blood Prince'
       session.flush()
       entry = list(Book.select())
       assert len(entry) is 1


Best regards,
Dakila


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to