This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author exarkun
Recipients exarkun, ngie, purcell, rhettinger
Date 2009-03-23.11:41:19
SpamBayes Score 1.784201e-08
Marked as misclassified No
Message-id <1237808485.08.0.952624691101.issue5538@psf.upfronthosting.co.za>
In-reply-to
Content
Here's one:

class ReactorShutdownInteraction(unittest.TestCase):
    """Test reactor shutdown interaction"""

    def setUp(self):
        """Start a UDP port"""
        self.server = Server()
        self.port = reactor.listenUDP(0, self.server, interface='127.0.0.1')

    def tearDown(self):
        """Stop the UDP port"""
        return self.port.stopListening()


Perhaps a feature like trial's `addCleanup´ should be added.  This lets
you deal with cleanup in a somewhat simpler way.  For example, rewriting
the above:

class ReactorShutdownInteraction(unittest.TestCase):
    """Test reactor shutdown interaction"""

    def setUp(self):
        """Start a UDP port"""
        self.server = Server()
        self.port = reactor.listenUDP(0, self.server, interface='127.0.0.1')
        # Stop the UDP port after the test completes.
        self.addCleanup(self.port.stopListening)
History
Date User Action Args
2009-03-23 11:41:25exarkunsetrecipients: + exarkun, rhettinger, purcell, ngie
2009-03-23 11:41:25exarkunsetmessageid: <1237808485.08.0.952624691101.issue5538@psf.upfronthosting.co.za>
2009-03-23 11:41:19exarkunlinkissue5538 messages
2009-03-23 11:41:19exarkuncreate