The tests were completely ad-hoc and did not use unittest or any other library. They had a hand-rolled runner which ran all the functions like test_one_one from a script. 

The odd thing is that Python 2.7 + py.test + the functools.wraps version of the decorators worked OK. 

Could it be that I have inadvertently turned the logging module on and output from that is confusing the py.test runner?

Thanks,

Sarah


On Thu, Jan 23, 2014 at 6:08 PM, holger krekel <holger@merlinux.eu> wrote:
Hi Sarah,

On Wed, Jan 22, 2014 at 21:21 +0000, Sarah Mount wrote:
> Hi there,
>
> I am currently converting some very idiosyncratic hand-rolled tests into
> more sensible unit tests with pytest. I had a problem running tests which
> dealt with decorators and following the advice here:
>
> http://stackoverflow.com/questions/19614658/how-do-i-make-pytest-fixtures-work-with-decorated-functions
>
> I refactored all my decorators to use the decorator library rather than
> functools.wraps.
>
> The win there was that now the Python 2.7 version of my code behaves in the
> same way as the Python 3.3 code (whereas before the 2.7 code passed and the
> 3.3 code errored). The fail is that now none of the tests run at all!
>
> I tried running tests without py.test (as in: python -m
> mylib.test.test_one) and they ran as expected. If I try to use the library
> just from a REPL session it seems OK. I suspect that the issue has occurred
> because I haven't yet understood where to use pytest fixtures.
>
> The (simplified) code looks roughly like this:
>
> ### FILE base.py
>
> @process
> def foo(channel):
>     channel.write(100)
>
> @process
> def bar(channel):
>     channel.read()
>
> ### FILE test_one.py
>
> def test_one_one():
>     channel = Channel()
>     par(foo(channel), bar(channel)).start()

Could you post the code that runs under the unittests framework
as well?

The test looks OK, maybe "py.test -s mylib" (don't capture output)
would give a clue why the test run bails out the way it does.

best,
holger

>
>
> And the results look like this:
>
> $ py.test mylib/
> ================================================================ test
> session starts
> =================================================================
> platform linux2 -- Python 2.7.5 -- pytest-2.5.1
> collected 44 items
>
> mylib/test/test_one.py (venv)$
>
>
> I have tried putting the @pytest.fixture decorator on both the functions in
> base.py and those in test_one.py but neither works.
>
> Any ideas?
>
> Thanks,
>
> Sarah
>
> --
> Sarah Mount, Senior Lecturer, University of Wolverhampton
> website:  http://www.snim2.org/
> twitter: @snim2

> _______________________________________________
> Pytest-dev mailing list
> Pytest-dev@python.org
> https://mail.python.org/mailman/listinfo/pytest-dev




--
Sarah Mount, Senior Lecturer, University of Wolverhampton
website:  http://www.snim2.org/
twitter: @snim2