Hi Vyachselav,

On Tue, Apr 05, 2011 at 11:42 -0400, Vyacheslav Rafalskiy wrote:
> Hi Holger and list members,
> 
> I have been using py.test for some time after switching from nose and
> quite happy with it.
> However, when migrating from 1.3.1 to 2.0.2 I hit a couple of snags,
> which makes me hesitate.
> Perhaps you can help me.

can try but am only online intermittently currently.

> 1. Just to clear the point. I understand from another post that
> option_xxxx variables
> in conftest.py are gone and recommended replacement is to use
> pytest_cmdline_preparse().
> Is that so?

Not exactly.  You can use a .ini file to add command line options:

    http://pytest.org/customize.html#adding-default-options

Or do you need to do something more dynamic?  In that case
you could play with pytest_cmdline_preparse, indeed.

> 2. The new behavior is that even if you run py.test --help, the
> pytest_configure() is still run.
> In my case pytest_configure() does quite a bit of heavy lifting and
> raises exceptions at
> wrong parameters. The result is that if the parameter is wrong I
> cannot use help to find
> out what is the right parameter. Of course, the workaround could be:
> 
> def pytest_configure(config):
>     if config.getvalue('help'):
>         return
>     ...
> 
> but it seems ugly. Am I in a wrong hook?

You could try pytest_sessionstart(session) and access session.config
for the config object.

> 3. In my pytest_configure() there are numerous conditions when it can
> fail. For this
> conditions I have exceptions with specially crafted messages, intended
> for different
> people. Now they are gone, replaced by a long and scary listing with every 
> line
> prepended with INTERNALERROR. What is internal about it? Can I continue 
> managing
> my configuration errors?

Sure, you should be able to. I guess it was a bit of an incident that
failures in pytest_configure were shown nicely.  I am not quite sure
immediately what the best way to relay "global" configuration messages
to the user is.  If you'd use "funcargs" and the "session" scope for
setting up resources then it would show nicely.  Feel free to open
a feature/enhancement request to have py.test show failures
in sessionstart or configure hooks in a way that helps you.
This way we can write a specific test and make sure it works
also in the future.

best,
holger
_______________________________________________
py-dev mailing list
py-dev@codespeak.net
http://codespeak.net/mailman/listinfo/py-dev

Reply via email to