On 4/27/10 7:27 AM, Chris Withers wrote:
> Hi All,
>
> 19.3 in the book covers writing integration tests by loading zcml.
> In a rare lack of symetry for the book, it doesn't cover the same for
> imperative configuration.
>
> Where can I find integration testing examples when using imperative
> configuration?

The docs use a test case like so:

    class ViewIntegrationTests(unittest.TestCase):
        def setUp(self):
            import myapp
            self.config = Configurator(package=myapp)
            self.config.begin()
            self.config.load_zcml('myapp:configure.zcml')

        def tearDown(self):
            """ Clear out the application registry """
            self.config.end()

Instead of calling config.load_zcml there, do whatever your application does to 
configure itself in its run.py (often .scan()), e.g.:

    class ViewIntegrationTests(unittest.TestCase):
        def setUp(self):
            import myapp
            self.config = Configurator(package=myapp)
            self.config.begin()
            self.config.scan()

        def tearDown(self):
            """ Clear out the application registry """
            self.config.end()


_______________________________________________
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev

Reply via email to