[Distutils] zope.testrunner behavior change
Gary Poster
gary.poster at canonical.com
Mon Aug 30 16:08:58 CEST 2010
On Aug 30, 2010, at 7:09 AM, Barry Warsaw wrote:
> I'm just back from a mini-vacation. Before I left, I upgrade the Mailman 3
> branch to use buildout 1.5, but I experienced a build failure [1] and a bunch
> of test failures. Gary fixed all the build problems (thanks!) and I think
> released a new zope.testrunner package that got my branch back into working
> state.
>
> Mostly. I had one test failure that was fairly easy to fix, but it pointed to
> a change in zope.testrunner. This may be a question better suited to the TIP
> list, but well, I'll send it here as a follow up to my buildout issues. ;)
>
> The diff should illustrate the behavior change in z.t that broke the test:
>
> % bzr diff -c 6934
> === modified file 'src/mailman/app/docs/hooks.txt'
> --- src/mailman/app/docs/hooks.txt 2010-01-12 13:27:38 +0000
> +++ src/mailman/app/docs/hooks.txt 2010-08-30 01:00:26 +0000
> @@ -51,7 +51,8 @@
>>>> def call():
> ... proc = subprocess.Popen(
> ... 'bin/mailman lists --domain ignore -q'.split(),
> - ... cwd='../..', # testrunner runs from ./parts/test
> + ... # testrunner runs from ./parts/test/working-directory
> + ... cwd='../../..',
> ... env=dict(MAILMAN_CONFIG_FILE=config_path,
> ... PYTHONPATH=config_directory),
> ... stdout=subprocess.PIPE, stderr=subprocess.PIPE)
>
>
> The test is trying to run a script that gets built into the bin directory of
> the built-out tree. I had to set cwd in order to find the bin directory. I
> probably could have used other landmarks to more dynamically find the bin
> directory, but this seemed expedient... until z.t changed the cwd in the new
> version.
That was a (my) change in zc.recipe.testrunner, not in zope.testrunner.
>
> So my question is: would it make sense to be able to ask zope.testrunner where
> it's running from, so that I don't have to hard code cwd? Better still would
> be a function in z.t that I could call that would get me back to root
> directory. E.g. something like:
>
> ... cwd=zope.testrunner.root_directory()
>
> Thoughts? It's not that big of a deal, but I don't like that my test relies
> on undocumented zope.testrunner behavior.
I think it is more a buildout question, and buildout does offer a way of getting that information when you are writing scripts. ${buildout: directory} is available in the .cfg files for script initialization (stuff it in an environ variable, maybe?), and of course can be also used in templating solutions like z3c.recipe.filetemplate.
Is that sufficient for a solution?
I don't know if the zope.testrunner would actually be able to give you the answer you want, but I don't know that package very well.
Gary
More information about the Distutils-SIG
mailing list