<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 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 class="HOEnZb"><font color="#888888"><br>
    <br>
    <br>
    Jens</font></span><div><div class="h5"><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 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 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 href="mailto:Pytest-dev@python.org" target="_blank">Pytest-dev@python.org</a><br>
                          <a 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 href="http://billiger.de" target="_blank">billiger.de</a> solute gmbh
                    Zeppelinstraße 15 D-76185 Karlsruhe Tel: <a href="tel:%2B49%20%280%29721%20-%2086956-24" value="+497218695624" target="_blank">+49 (0)721 -
                      86956-24</a> Fax: <a href="tel:%2B49%20%280%29721%20-%2086956-66" value="+497218695666" target="_blank">+49 (0)721 -
                      86956-66</a> E-Mail: <a href="mailto:rsc@solute.de" target="_blank">rsc@solute.de</a>
                    Web: <a 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 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 href="http://billiger.de" target="_blank">billiger.de</a> solute gmbh
      Zeppelinstraße 15
      D-76185 Karlsruhe Tel: <a href="tel:%2B49%20%280%29721%20-%2086956-24" value="+497218695624" target="_blank">+49 (0)721 - 86956-24</a>
      Fax: <a href="tel:%2B49%20%280%29721%20-%2086956-66" value="+497218695666" target="_blank">+49 (0)721 - 86956-66</a>
      E-Mail: <a href="mailto:rsc@solute.de" target="_blank">rsc@solute.de</a>
      Web: <a 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 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>