Skip to content

Instantly share code, notes, and snippets.

@nguyendv
Created March 14, 2018 15:20
Show Gist options
  • Save nguyendv/29acc797ca98926f8e70881ea697437f to your computer and use it in GitHub Desktop.
Save nguyendv/29acc797ca98926f8e70881ea697437f to your computer and use it in GitHub Desktop.
@pytest.fixture
def db_conn():
psycopg2.connect("dbname=test user=postgres")
yield conn
# start cleaning up
conn.close()
def test_foo(db_conn):
result = db_conn.execute(a_sql_statement)
assert result == expected_value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment