On Mon, Apr 20, 2015 at 12:04 +0800, Eduardo Schettino wrote:
> On Sun, Apr 19, 2015 at 3:32 PM, holger krekel <[email protected]> wrote:
> 
> > On Sat, Apr 18, 2015 at 22:53 +0200, Anatoly Bubenkov wrote:
> > > Its not always enough and possible to use inline run, but indeed helps
> > for
> > > pytest-cov
> >
> > I'd like to make inline_run behave as much as possible like runpytest()
> > (which creates a subprocess).  One issue is capturing output, what are
> > others in your experience?
> >
> > holger
> >
> >
> To capture the output when needed, I just used the `capsys` fixture.
> 
> Another issue I had was modifying a test module and re-running its tests.
> Of course the the original module was cached by the import system,
> so I had to delete it before the second run. Something like: `del
> sys.modules['test_xxx']`.

There is some code in the pytester plugin which takes care of this:

        for name, mod in list(sys.modules.items()):
            if mod:
                fn = getattr(mod, '__file__', None)
                if fn and fn.startswith(str(self.tmpdir)):
                    del sys.modules[name]


but it's only called at the end of a test function.  We could make it
callable as a helper on "testdir" so you call it in between.  Or,
actually, we could do this cleanup after each inline_run() call
automatically.  If you agree do you want to submit a little PR (to
default) and make sure it works for you?

best,
holger
_______________________________________________
pytest-dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pytest-dev

Reply via email to