Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #592 (closed defect: fixed)

Opened 13 years ago

Last modified 12 years ago

[PATCH] DBTest doesn't create tables for SQLObject classes imported into the provided model

Reported by: nyenyec Owned by: anonymous
Priority: normal Milestone: 0.9
Component: TurboGears Version:
Severity: normal Keywords:
Cc:

Description

Currently testutil.DBTest looks like this:

class DBTest(unittest.TestCase):
    model = None

    def setUp(self):
        if not self.model:
            self.model = get_model()
            if not self.model:
                raise "Unable to run database tests without a model"

        for item in self.model.__dict__.values():
            if inspect.isclass(item) and issubclass(item,
                sqlobject.SQLObject) and item != sqlobject.SQLObject and \
                item.__module__ == self.model.__name__:
                item.createTable(ifNotExists=True)

In my unit tests I rely on the TG_User tables but these won't be included because the condition

item.__module__ == self.model.__name__

will evaluate to false.

I'm not sure why this is included at all. I don't think it is a problem if tables are created for all SQLObject subclass instances in the provided model. OTOH, tests that rely on imported TG_User classes for example, will all fail, because the required tables will be missing.

Attachments

DBTest_imported_SQLObjects.patch Download (705 bytes) - added by nyenyec 13 years ago.

Change History

Changed 13 years ago by nyenyec

comment:1 Changed 13 years ago by nyenyec

  • Summary changed from DBTest doesn't create tables for SQLObject classes imported into the provided model to [PATCH] DBTest doesn't create tables for SQLObject classes imported into the provided model

comment:2 Changed 13 years ago by kevin

  • Status changed from new to closed
  • Resolution set to fixed

All existing tests pass with this. Committed in [830]. Thanks!

Note: See TracTickets for help on using tickets.