Initial test-setup
create testclient-fixture ignore all pep8-errors
This commit is contained in:
parent
5979fa8bfc
commit
6aa4957f6b
34
bepasty/tests/conftest.py
Normal file
34
bepasty/tests/conftest.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
from os import close, unlink
|
||||||
|
from random import random
|
||||||
|
from tempfile import mkstemp
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from bepasty.app import create_app, create_storage
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope='module')
|
||||||
|
def testclient(request):
|
||||||
|
'''
|
||||||
|
creates a Flask-testclient instance for bepasty
|
||||||
|
'''
|
||||||
|
app = create_app()
|
||||||
|
db_file, app.config['DATABASE'] = mkstemp()
|
||||||
|
# reset default permissions
|
||||||
|
app.config['DEFAULT_PERMISSIONS'] = ''
|
||||||
|
# setup a secret key
|
||||||
|
app.config['SECRET_KEY'] = str(random())
|
||||||
|
# setup permissions
|
||||||
|
app.config['PERMISSIONS'] = {
|
||||||
|
'l': 'list',
|
||||||
|
'c': 'create',
|
||||||
|
'r': 'read',
|
||||||
|
'd': 'delete',
|
||||||
|
'a': 'admin'
|
||||||
|
}
|
||||||
|
|
||||||
|
def teardown():
|
||||||
|
close(db_file)
|
||||||
|
unlink(app.config['DATABASE'])
|
||||||
|
request.addfinalizer(teardown)
|
||||||
|
return app.test_client()
|
@ -4,6 +4,10 @@ norecursedirs = .git .tox build
|
|||||||
pep8ignore =
|
pep8ignore =
|
||||||
*.py E124 # closing bracket does not match visual indentation (behaves strange!?)
|
*.py E124 # closing bracket does not match visual indentation (behaves strange!?)
|
||||||
*.py E125 # continuation line does not distinguish itself from next logical line (difficult to avoid!)
|
*.py E125 # continuation line does not distinguish itself from next logical line (difficult to avoid!)
|
||||||
|
*.py E402
|
||||||
|
*.py E302
|
||||||
|
*.py E303
|
||||||
|
*.py E731
|
||||||
docs/source/conf.py ALL # sphinx stuff, automatically generated, don't check this
|
docs/source/conf.py ALL # sphinx stuff, automatically generated, don't check this
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user