> Well, a couple ways.  You can use multiple configuration files (not just
> test.ini).  You can also pass arguments to loadapp(), like
> loadapp('test.ini', db='something'), then use %(db)s in your ini file to
> substitute that value in.

Thanks for the various solutions.  I like the db='something' approach,
but decided that a good test would verify that the settings in
the .ini file are working in addition to my code, so I added some code
to parse the test.ini file and dump it into a temporary file with the
correct settings.

Here's the code (could probably be improved, such as using the os
temporary files) if anybody comes across this again:

    # write a new .ini file with repo_dir_listing_enabled = false
    import os.path,re
    szConfig = open(os.path.join(config['root'],'test.ini')).read()
    szConfigNew = re.sub('\nrepo_dir_listing_enabled\s*=\s*.*?\n',
                         '\nrepo_dir_listing_enabled = false\n',
                         szConfig
                         )
    szTempIni = os.path.join(config['root'],'test-dir-disabled.ini')
    open(szTempIni,'w').write(szConfigNew)

    # Reload the application using the new ini and make the request
    wsgiapp = loadapp('config:test-dir-disabled.ini',
relative_to=config['root'])
    self.app = paste.fixture.TestApp(wsgiapp)

    # request a directory listing
    response = self.app.get('/repository/',expect_errors=True)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to