<div dir="ltr">While it&#39;s difficult to debug without seeing your actual test code (your example doesn&#39;t use session or setup_session), it seems like you may be close. If your fixture&#39;s name is &#39;setup_session&#39;, that&#39;s the name you need to use within the test function - not &#39;session&#39;.<br>
<div class="gmail_extra"><br></div><div class="gmail_extra">cheers<br>Brianna<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 25 October 2013 08:02, Paradox <span dir="ltr">&lt;<a href="mailto:paradox@pobox.com" target="_blank">paradox@pobox.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I am trying to understand fixtures and how they are used.  I am writing tests for my program that interacts with an Sqlite database using Sqlalchemy.  I am working on Python 2.7.5 in Ubuntu 13.10.<br>

<br>
My setup_session fixture is:<br>
<br>
=================<br>
@pytest.fixture (autouse = True)<br>
def setup_session():<br>
    db_file = &#39;database.db&#39;<br>
    engine = create_engine(&#39;sqlite:///&#39; + db_file, echo = True)<br>
    Base = declarative_base()<br>
    Session = sessionmaker(bind=engine)<br>
    session = Session()<br>
    return session<br>
==================<br>
<br>
Then when I try to use that fixture in a test it is something like:<br>
==================<br>
def test_get_id_of_row(setup_<u></u>session):<br>
    assert(get_id_of_row(&#39;cell known to be in test data&#39;)==1)<br>
==================<br>
<br>
I am getting an error:<br>
==================<br>
NameError: global name &#39;session&#39; is not defined<br>
==================<br>
<br>
Shouldn&#39;t that be taken care of by passing the setup_session fixture to the test function?  There is something I don&#39;t get about fixtures and would appreciate any pointers on where to read to better understand, I have read the <a href="http://pytest.org" target="_blank">pytest.org</a> site on fixtures several times and it is still not sinking in!<br>

<br>
thomas<br>
<br>
______________________________<u></u>_________________<br>
testing-in-python mailing list<br>
<a href="mailto:testing-in-python@lists.idyll.org" target="_blank">testing-in-python@lists.idyll.<u></u>org</a><br>
<a href="http://lists.idyll.org/listinfo/testing-in-python" target="_blank">http://lists.idyll.org/<u></u>listinfo/testing-in-python</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>They&#39;ve just been waiting in a mountain for the right moment: <a href="http://modernthings.org/">http://modernthings.org/</a>
</div></div>