When you say you created a setup fixture but it didn't work, what
didn't work exactly?

For example, if you just did something like this:

def setup():
     engine = ...
     Session = ...
     session = Session()

...then that won't work because session is a local variable inside the
setup function. At a minimum you'd need to put something like "global
session" at the beginning of the function.

Simon



Simon and Panov,

I really appreciate your help with this, I think I have it worked out
now.  I will document what I did in case others have similar problems.

In py.test you can define a fixture (in the tests file) like:

@py.test fixture
def setup_session():
    engine = create_engine('sqlite:///mydatabasefile.db',echo=True)
    Session = sessionmaker(bind=engine)
    session = Session()
    return session

Then in the test you need to pass the fixture function as an argument:

def get_list_of_filesprocessed(setup_session):
    result = get_list_of_filesprocessed()
    assert(result[0] == 'Expected first file name')

I was not properly passing the fixture to the test.

Thanks again for the assistance!

thomas



--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to