Skip to content

Commit aa2293a

Browse files
committed
Fix travis tests
1 parent 9c198a2 commit aa2293a

3 files changed

Lines changed: 11 additions & 9 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ build
55
.tox
66
flycheck-*
77
dist
8-
.env
8+
.env
9+
.cache

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ test: env
44
.env/bin/py.test -x tests
55

66
travis_test: env
7-
.env/bin/py.test
7+
PYTHONPATH=.env/mailboxer .env/bin/py.test
88

99
env: .env/.up-to-date
1010

@@ -15,7 +15,6 @@ env: .env/.up-to-date
1515
.env/bin/pip install -r ./mailboxer_python.egg-info/requires.txt
1616
.env/bin/pip install pytest Flask-Loopback
1717
test -d .env/mailboxer || git clone https://github.com/vmalloc/mailboxer .env/mailboxer
18-
.env/bin/pip install -r .env/mailboxer/base_requirements.txt
19-
.env/bin/pip install -r .env/mailboxer/flask_app/pip_requirements.txt
18+
.env/bin/pip install -r .env/mailboxer/deps/base.txt -r .env/mailboxer/deps/develop.txt -r .env/mailboxer/deps/app.txt
2019
touch $@
2120

tests/conftest.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
sys.path.insert(0, os.path.join(
1515
os.path.abspath(os.path.dirname(__file__)),
1616
"..", ".env", "mailboxer"))
17-
from flask_app.app import app
17+
from flask_app.app import create_app
1818
from flask_app import models
1919

2020
def pytest_addoption(parser):
@@ -26,21 +26,23 @@ def db_engine(request):
2626
tmpdir = tempfile.mkdtemp()
2727
subprocess.check_call("pg_ctl init -D {0} -w".format(tmpdir), shell=True)
2828
subprocess.check_call("pg_ctl start -D {0} -w".format(tmpdir), shell=True)
29+
2930
@request.addfinalizer
3031
def finalize():
3132
subprocess.check_call("pg_ctl stop -D {0} -w -m immediate".format(tmpdir), shell=True)
3233
shutil.rmtree(tmpdir)
3334

3435
subprocess.check_call("createdb mailboxer", shell=True)
3536

36-
models.db.session.close()
37-
models.db.drop_all()
38-
models.db.create_all()
37+
with create_app().app_context():
38+
models.db.session.close()
39+
models.db.drop_all()
40+
models.db.create_all()
3941

4042

4143
@pytest.fixture(scope="session")
4244
def mailboxer_url(request, db_engine):
43-
loopback = FlaskLoopback(app)
45+
loopback = FlaskLoopback(create_app())
4446
hostname = str(uuid.uuid1())
4547
loopback.activate_address((hostname, 80))
4648
@request.addfinalizer

0 commit comments

Comments
 (0)