~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/canonical/testing/layers.py

  • Committer: William Grant
  • Date: 2011-09-24 03:29:18 UTC
  • mto: This revision was merged to the branch mainline in revision 14030.
  • Revision ID: william.grant@canonical.com-20110924032918-oha8qoer8a44655g
Replace initZopeless mostly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1532
1532
    @classmethod
1533
1533
    @profiled
1534
1534
    def testSetUp(cls):
1535
 
        if ZopelessTransactionManager._installed is not None:
1536
 
            raise LayerIsolationError(
1537
 
                "Last test using Zopeless failed to tearDown correctly")
1538
 
        ZopelessTransactionManager.initZopeless(dbuser='launchpad_main')
 
1535
        dbconfig.override(isolation_level='read_committed')
1539
1536
        # XXX wgrant 2011-09-24 bug=29744: initZopeless used to do this.
1540
1537
        # Tests that still need it should eventually set this directly,
1541
1538
        # so the whole layer is not polluted.
1547
1544
    @classmethod
1548
1545
    @profiled
1549
1546
    def testTearDown(cls):
1550
 
        ZopelessTransactionManager.uninstall()
1551
 
        if ZopelessTransactionManager._installed is not None:
1552
 
            raise LayerInvariantError(
1553
 
                "Failed to uninstall ZopelessTransactionManager")
 
1547
        dbconfig.reset()
1554
1548
        # LaunchpadScriptLayer will disconnect the stores for us.
1555
1549
 
1556
1550
        # XXX wgrant 2011-09-24 bug=29744: uninstall used to do this.
1571
1565
    @classmethod
1572
1566
    @profiled
1573
1567
    def switchDbUser(cls, dbuser):
1574
 
        LaunchpadZopelessLayer._alterConnection(dbuser=dbuser)
1575
 
 
1576
 
    @classmethod
1577
 
    @profiled
1578
 
    def _alterConnection(cls, **kw):
1579
 
        """Reset the connection, and reopen the connection by calling
1580
 
        initZopeless with the given keyword arguments.
1581
 
        """
1582
 
        ZopelessTransactionManager.uninstall()
1583
 
        ZopelessTransactionManager.initZopeless(**kw)
 
1568
        dbconfig.override(dbuser=dbuser)
 
1569
        ZopelessTransactionManager._reset_stores()
1584
1570
 
1585
1571
 
1586
1572
class ExperimentalLaunchpadZopelessLayer(LaunchpadZopelessLayer):