Skip to content

Instantly share code, notes, and snippets.

@OrangeTux
Created January 9, 2014 10:57
Show Gist options
  • Save OrangeTux/8332464 to your computer and use it in GitHub Desktop.
Save OrangeTux/8332464 to your computer and use it in GitHub Desktop.
Regenerate database with Py.test.
#conftest.py
import pytest
@pytest.fixture
def db():
test_db.create_all()
return test_db
@pytest.fixture
def recreate_db():
test_db.drop_all()
return db()
# test.py
import pytest
@pytest.mark.usefixtures('recreate_db')
def test_something():
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment