<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Okay, I clearly get what Guido said, but I say: let the folks do
what they want to! pytest now kind of forces me to think like Guido;<br>
<br>
<br>
Jens<br>
<br>
<br>
<br>
<div class="moz-cite-prefix">On 09/25/2014 02:23 PM, Anatoly
Bubenkov wrote:<br>
</div>
<blockquote
cite="mid:CACTnz+GqYcyeQUj4KKCR+6EVhd_RbcvtPM9edSgtAdNwehMo6w@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<div dir="ltr">exactly, just throw away all those classes - Guido
said, classes are NOT namespaces
<div>you might only need classes for the polymorphism, but it's
no-use in the tests</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 25 September 2014 14:20, Jens
Hoffmann <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:jh@solute.de" target="_blank">jh@solute.de</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> This gives me a
little pain, since I always liked to organize my tests
OO-like, with classes etc; the docs call pytest fixtures:
explicit, modular, scalable; but for me "decorating
classes and methods" is a tiny bit of magic that forces me
to leave the pure OO way and to think a little more
functional;<br>
<br>
<br>
Jens
<div>
<div class="h5"><br>
<br>
<br>
<div>On 09/25/2014 02:09 PM, Anatoly Bubenkov wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">the thing is, fixtures have proper
dependency injection working
<div>but combing them with oldish setup_ methods
doesn't always work properly out of the box -
just because it's impossible to determine the
'right' order, because there's no 'right' order,
it's all up to you to determine the dependency
tree</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 25 September 2014
14:06, Jens Hoffmann <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:jh@solute.de" target="_blank">jh@solute.de</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0
0 0 .8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> okay,
I'll kill them... thank you for your quick
responses
<div>
<div><br>
<br>
<br>
<div>On 09/25/2014 02:03 PM, Anatoly
Bubenkov wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">setup_ methods should
just die :)
<div>use fixtures everywhere instead</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 25
September 2014 14:01, Jens
Hoffmann <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:jh@solute.de"
target="_blank">jh@solute.de</a>></span>
wrote:<br>
<blockquote class="gmail_quote"
style="margin:0 0 0
.8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div bgcolor="#FFFFFF"
text="#000000"> Okay, writing
the example I found out what
the actual problem is:<br>
<br>
<br>
In the minimal example the
fixture *is* executed, before
any test but *after* my test
classes setup_method.<br>
<br>
<br>
I though expect that a session
fixture is executed also
before a classes setup_method
(use case: fixture sets up DB,
setup_method sets up some
tables);<br>
<br>
<br>
Am I wrong?<span><font
color="#888888"><br>
<br>
<br>
Jens</font></span>
<div>
<div><br>
<br>
<br>
<div>On 09/25/2014 01:18
PM, Anatoly Bubenkov
wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">please
upload fully
reproducable small
example somewhere
<div>or, ideally,
create a test and
have a PR with it</div>
</div>
<div class="gmail_extra"><br>
<div
class="gmail_quote">On
25 September 2014
13:14, Jens Hoffmann
<span dir="ltr"><<a
moz-do-not-send="true" href="mailto:jh@solute.de" target="_blank">jh@solute.de</a>></span>
wrote:<br>
<blockquote
class="gmail_quote"
style="margin:0 0
0
.8ex;border-left:1px
#ccc
solid;padding-left:1ex">
<div
bgcolor="#FFFFFF"
text="#000000">
Yes, the
directories test
and test/module
all contain a
__init__.py;
sorry, that I
didnt mention
this important
info.<br>
<br>
So from your
question I guess
that you expect
py.test to find
and execute
conftest.py in
all the cases
shown?<br>
<br>
<br>
Jens
<div>
<div><br>
<br>
<br>
<div>On
09/25/2014
01:09 PM,
Anatoly
Bubenkov
wrote:<br>
</div>
<blockquote
type="cite">
<div dir="ltr">did
you add
__init__.py in
all folders?<br>
</div>
<div
class="gmail_extra"><br>
<div
class="gmail_quote">On
25 September
2014 12:35,
Jens Hoffmann
<span
dir="ltr"><<a
moz-do-not-send="true" href="mailto:jh@solute.de" target="_blank">jh@solute.de</a>></span>
wrote:<br>
<blockquote
class="gmail_quote"
style="margin:0
0 0
.8ex;border-left:1px
#ccc
solid;padding-left:1ex">Hi,<br>
<br>
<br>
we are working
with pytest
2.6.2 and I
run into a
problem with
my conftest
session
fixture setup.<br>
<br>
My project
structure
looks
something like
this:<br>
<br>
.<br>
├── project<br>
│ └── module<br>
│ └── foo.py<br>
└── test<br>
├──
conftest.py<br>
└── module<br>
└──
test_foo.py<br>
<br>
<br>
conftest.py
contains a
single fixture
with
scope="session"
and
autouse=True,
setting up
some database
that is needed
for every
single
unittest. So
also
test_foo.py
depends on
that database
setup.<br>
<br>
Now some
py.test runs:<br>
<br>
$ py.test<br>
=>
conftest.py
called,
database setup
properly,
tests pass<br>
<br>
$ py.test
test/module<br>
=> tests
fail, fixture
in conftest.py
not executed<br>
<br>
$ py.test
test/module/test_foo.py<br>
=> tests
fail, fixture
in conftest.py
not executed<br>
<br>
$ py.test -k
MyTestClassContainedInTestFooDotPy<br>
=> tests
fail, fixture
in conftest.py
not executed<br>
<br>
<br>
Now my
question/problem:
Are all these
outcoms
expected
behaviour? I
hoped that all
the runs would
pass, that is
execute my
session
fixture so
that I wont
need to always
run my whole
test suite.<br>
<br>
<br>
Thank you for
your answer,<br>
Jens<br>
<br>
_______________________________________________<br>
Pytest-dev
mailing list<br>
<a
moz-do-not-send="true"
href="mailto:Pytest-dev@python.org" target="_blank">Pytest-dev@python.org</a><br>
<a
moz-do-not-send="true"
href="https://mail.python.org/mailman/listinfo/pytest-dev"
target="_blank">https://mail.python.org/mailman/listinfo/pytest-dev</a><br>
</blockquote>
</div>
<br>
<br
clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr">Anatoly
Bubenkov<br>
</div>
</div>
</blockquote>
<br>
</div>
</div>
<span><font
color="#888888">
<div>-- <br>
Jens Hoffmann
Softwareentwickler
Datamanagement
<a
moz-do-not-send="true"
href="http://billiger.de" target="_blank">billiger.de</a> solute gmbh
Zeppelinstraße
15 D-76185
Karlsruhe Tel:
<a
moz-do-not-send="true"
href="tel:%2B49%20%280%29721%20-%2086956-24" value="+497218695624"
target="_blank">+49
(0)721 -
86956-24</a>
Fax: <a
moz-do-not-send="true"
href="tel:%2B49%20%280%29721%20-%2086956-66" value="+497218695666"
target="_blank">+49
(0)721 -
86956-66</a>
E-Mail: <a
moz-do-not-send="true"
href="mailto:rsc@solute.de" target="_blank">rsc@solute.de</a> Web: <a
moz-do-not-send="true"
href="http://www.billiger.de" target="_blank">http://www.billiger.de</a>
Geschäftsführer:
Lorenz
Petersen Sitz:
Karlsruhe
Registergericht:
Amtsgericht
Mannheim
Registernummer:
HRB 110579
Umsatzsteueridentifikationsnummer:
DE234663798 <a
moz-do-not-send="true"
href="http://cdn.billiger.com/static/mail/billiger_today_logo_dunkel_20140911.png"
target="_blank">http://cdn.billiger.com/static/mail/billiger_today_logo_dunkel_20140911.png</a></div>
</font></span></div>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr">Anatoly
Bubenkov<br>
</div>
</div>
</blockquote>
<br>
<div>-- <br>
Jens Hoffmann
Softwareentwickler
Datamanagement <a
moz-do-not-send="true"
href="http://billiger.de" target="_blank">billiger.de</a> solute gmbh
Zeppelinstraße 15
D-76185 Karlsruhe Tel: <a
moz-do-not-send="true"
href="tel:%2B49%20%280%29721%20-%2086956-24" value="+497218695624"
target="_blank">+49
(0)721 - 86956-24</a>
Fax: <a
moz-do-not-send="true"
href="tel:%2B49%20%280%29721%20-%2086956-66" value="+497218695666"
target="_blank">+49
(0)721 - 86956-66</a>
E-Mail: <a
moz-do-not-send="true"
href="mailto:rsc@solute.de" target="_blank">rsc@solute.de</a> Web: <a
moz-do-not-send="true"
href="http://www.billiger.de" target="_blank">http://www.billiger.de</a>
Geschäftsführer: Lorenz
Petersen Sitz: Karlsruhe
Registergericht:
Amtsgericht Mannheim
Registernummer: HRB
110579
Umsatzsteueridentifikationsnummer:
DE234663798 <a
moz-do-not-send="true"
href="http://cdn.billiger.com/static/mail/billiger_today_logo_dunkel_20140911.png"
target="_blank">http://cdn.billiger.com/static/mail/billiger_today_logo_dunkel_20140911.png</a></div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr">Anatoly Bubenkov<br>
</div>
</div>
</blockquote>
<br>
<div>-- <br>
Jens Hoffmann Softwareentwickler
Datamanagement <a
moz-do-not-send="true"
href="http://billiger.de"
target="_blank">billiger.de</a>
solute gmbh Zeppelinstraße 15 D-76185
Karlsruhe Tel: <a
moz-do-not-send="true"
href="tel:%2B49%20%280%29721%20-%2086956-24"
value="+497218695624"
target="_blank">+49 (0)721 -
86956-24</a> Fax: <a
moz-do-not-send="true"
href="tel:%2B49%20%280%29721%20-%2086956-66"
value="+497218695666"
target="_blank">+49 (0)721 -
86956-66</a> E-Mail: <a
moz-do-not-send="true"
href="mailto:rsc@solute.de"
target="_blank">rsc@solute.de</a>
Web: <a moz-do-not-send="true"
href="http://www.billiger.de"
target="_blank">http://www.billiger.de</a>
Geschäftsführer: Lorenz Petersen Sitz:
Karlsruhe Registergericht: Amtsgericht
Mannheim Registernummer: HRB 110579
Umsatzsteueridentifikationsnummer:
DE234663798 <a moz-do-not-send="true"
href="http://cdn.billiger.com/static/mail/billiger_today_logo_dunkel_20140911.png"
target="_blank">http://cdn.billiger.com/static/mail/billiger_today_logo_dunkel_20140911.png</a></div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr">Anatoly Bubenkov<br>
</div>
</div>
</blockquote>
<br>
<div>-- <br>
Jens Hoffmann Softwareentwickler Datamanagement <a
moz-do-not-send="true" href="http://billiger.de"
target="_blank">billiger.de</a> solute gmbh
Zeppelinstraße 15 D-76185 Karlsruhe Tel: <a
moz-do-not-send="true"
href="tel:%2B49%20%280%29721%20-%2086956-24"
value="+497218695624" target="_blank">+49 (0)721 -
86956-24</a> Fax: <a moz-do-not-send="true"
href="tel:%2B49%20%280%29721%20-%2086956-66"
value="+497218695666" target="_blank">+49 (0)721 -
86956-66</a> E-Mail: <a moz-do-not-send="true"
href="mailto:rsc@solute.de" target="_blank">rsc@solute.de</a>
Web: <a moz-do-not-send="true"
href="http://www.billiger.de" target="_blank">http://www.billiger.de</a>
Geschäftsführer: Lorenz Petersen Sitz: Karlsruhe
Registergericht: Amtsgericht Mannheim
Registernummer: HRB 110579
Umsatzsteueridentifikationsnummer: DE234663798
<a moz-do-not-send="true"
href="http://cdn.billiger.com/static/mail/billiger_today_logo_dunkel_20140911.png"
target="_blank">http://cdn.billiger.com/static/mail/billiger_today_logo_dunkel_20140911.png</a></div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr">Anatoly Bubenkov<br>
</div>
</div>
</blockquote>
<br>
<div class="moz-signature">-- <br>
Jens Hoffmann
Softwareentwickler
billiger.de
solute gmbh
_______________________________________________________________
<a class="moz-txt-link-abbreviated" href="mailto:jh@solute.de">jh@solute.de</a>
<a class="moz-txt-link-freetext" href="http://www.billiger.de">http://www.billiger.de</a>
<a class="moz-txt-link-freetext" href="http://www.solute.de">http://www.solute.de</a>
_______________________________________________________________
Office Karlsruhe
Zeppelinstraße 15
D-76185 Karlsruhe
Tel: ...
Fax: ...
_______________________________________________________________
Geschäftsführer: Lorenz Petersen
Sitz: Karlsruhe
Registergericht: Amtsgericht Mannheim
Registernummer: HRB 110579
Umsatzsteueridentifikationsnummer: DE234663798</div>
</body>
</html>