def tearDown(self):
from .models.meta import Base
testing.tearDown()
transaction.abort()
Base.metadata.drop_all(self.engine)
python类tearDown()的实例源码
def tearDown(self):
testing.tearDown()
def tearDown(self):
DBSession.remove()
testing.tearDown()
def tearDown(self):
DBSession.remove()
testing.tearDown()
def tearDown(self):
testing.tearDown()
def tearDown(self):
testing.tearDown()
def tearDown(self):
testing.tearDown()
def csrf_app(request):
"""py.test fixture to set up a dummy app for CSRF testing.
:param request: pytest's FixtureRequest (internal class, cannot be hinted on a signature)
"""
session = DummySession()
config = testing.setUp()
config.set_default_csrf_options(require_csrf=True)
config.add_route("home", "/")
config.add_route("csrf_sample", "/csrf_sample")
config.add_route("csrf_exempt_sample", "/csrf_exempt_sample")
config.add_route("csrf_exempt_sample_context", "/csrf_exempt_sample_context")
config.add_route("csrf_sample_double_argument", "/csrf_sample_double_argument/{arg}")
config.add_route("csrf_exempt_sample_double_argument", "/csrf_exempt_sample_double_argument/{arg}")
config.scan(csrfsamples)
# We need sessions in order to use CSRF feature
def dummy_session_factory(secret):
# Return the same session over and over again
return session
config.set_session_factory(dummy_session_factory)
def teardown():
testing.tearDown()
app = TestApp(config.make_wsgi_app())
# Expose session data for tests to read
app.session = session
return app
def test_backup(dbsession, ini_settings):
"""Execute backup script with having our settings content."""
f = NamedTemporaryFile(delete=False)
temp_fname = f.name
f.close()
ini_settings["websauna.backup_script"] = "websauna.tests:backup_script.bash"
ini_settings["backup_test.filename"] = temp_fname
# We have some scoping issues with the dbsession here, make sure we close transaction at the end of the test
with transaction.manager:
init = get_init(dict(__file__=ini_settings["_ini_file"]), ini_settings)
init.run()
testing.setUp(registry=init.config.registry)
# Check we have faux AWS variable to export
secrets = get_secrets(get_current_registry())
assert "aws.access_key_id" in secrets
try:
# This will run the bash script above
backup_site()
# The result should be generated here
assert os.path.exists(temp_fname)
contents = io.open(temp_fname).read()
# test-secrets.ini, AWS access key
assert contents.strip() == "foo"
finally:
testing.tearDown()
def tearDown(self):
from .models.meta import Base
testing.tearDown()
transaction.abort()
Base.metadata.drop_all(self.engine)
def tearDown(self):
from .models.meta import Base
testing.tearDown()
transaction.abort()
Base.metadata.drop_all(self.engine)
def tearDown(self):
testing.tearDown()
def tearDown(self):
testing.tearDown()
clear_seen_by_of('Tobias')
clear_clicks_of('Tobias')
clear_seen_by_of('Björn')
clear_clicks_of('Björn')
def tearDown(self):
testing.tearDown()
def tearDown(self):
testing.tearDown()
def tearDown(self):
testing.tearDown()
def tearDown(self):
testing.tearDown()
def tearDown(self):
testing.tearDown()
def tearDown(self):
testing.tearDown()
def tearDown(self):
testing.tearDown()