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 #2244 (closed defect: fixed)

Opened 10 years ago

Last modified 10 years ago

Controller tests are not isolated because of the base test case (TestController)

Reported by: Gustavo Owned by: Gustavo
Priority: high Milestone: 2.0rc1
Component: Quickstart Templates Version: trunk
Severity: critical Keywords: fixture, test cases, isolation
Cc:

Description

I'm talking about {tg2-project}.tests.TestController:

  1. To set up to a correct, isolated fixture, the following lines should be defined in .setUp(), not in .__init__():
            conf_dir = config.here
            wsgiapp = loadapp('config:test.ini', relative_to=conf_dir)
            self.app = webtest.TestApp(wsgiapp)
    
  2. Like in pre-2.0b6 releases, "paster setup-app ..." should be run. But this time, from the .setUp() method.

This is, that base test case should look like this:

class TestController(object):
    def setUp(self):
        # Loading the application:
        conf_dir = config.here
        wsgiapp = loadapp('config:test.ini', relative_to=conf_dir)
        self.app = webtest.TestApp(wsgiapp)
        # Setting it up:
        test_file = os.path.join(conf_dir, 'test.ini')
        cmd = paste.script.appinstall.SetupCommand('setup-app')
        cmd.run([test_file])

    def tearDown(self):
        engine = config['pylons.app_globals'].sa_engine
        model.metadata.drop_all(engine)

If nobody opposes, I'll apply the proposed changes.

Change History

comment:1 Changed 10 years ago by Gustavo

  • Status changed from new to assigned
  • Summary changed from The base test case for controllers is not isolated to Controller tests are not isolated because of the base test case (TestController)

comment:2 Changed 10 years ago by Gustavo

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

Fixed in [6468]

Note: See TracTickets for help on using tickets.