1#!/usr/bin/env python 2""" 3pytest plugin script. 4 5This script is an extension to py.test which 6installs SQLAlchemy's testing plugin into the local environment. 7 8""" 9import os 10import sys 11 12if not sys.flags.no_user_site: 13 # this is needed so that test scenarios like "python setup.py test" 14 # work correctly, as well as plain "py.test". These commands assume 15 # that the package in question is locally present, but since we have 16 # ./lib/, we need to punch that in. 17 # We check no_user_site to honor the use of this flag. 18 sys.path.insert( 19 0, 20 os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "lib"), 21 ) 22 23# use bootstrapping so that test plugins are loaded 24# without touching the main library before coverage starts 25bootstrap_file = os.path.join( 26 os.path.dirname(__file__), 27 "..", 28 "lib", 29 "sqlalchemy", 30 "testing", 31 "plugin", 32 "bootstrap.py", 33) 34 35with open(bootstrap_file) as f: 36 code = compile(f.read(), "bootstrap.py", "exec") 37 to_bootstrap = "pytest" 38 exec(code, globals(), locals()) 39 from pytestplugin import * # noqa 40