def begin(self): # The tests require that the environment is currently set to en_US, to avoid # translated strings and use the default date/number/currency formatting os.environ['LC_ALL'] = 'en_US.UTF-8' os.environ['LANG'] = 'en_US.UTF-8' os.environ['LANGUAGE'] = 'en_US.UTF-8' # Set the default encoding to utf-8 just like pygtk used to do. # Maybe this will not be necessary in python3 reload(sys) sys.setdefaultencoding('utf-8') # If we import tests.base before Cover.setup() in the coverage plugin # is called the statistics will skip the modules imported by tests.base from stoqlib.database.testsuite import bootstrap_suite hostname = os.environ.get('STOQLIB_TEST_HOSTNAME') dbname = os.environ.get('STOQLIB_TEST_DBNAME') username = os.environ.get('STOQLIB_TEST_USERNAME') password = os.environ.get('STOQLIB_TEST_PASSWORD') port = int(os.environ.get('STOQLIB_TEST_PORT') or 0) quick = os.environ.get('STOQLIB_TEST_QUICK', None) is not None config = os.path.join(os.path.dirname(stoqlib.__file__), 'tests', 'config.py') if os.path.exists(config): exec(compile(open(config).read(), config, 'exec'), globals(), locals()) bootstrap_suite(address=hostname, dbname=dbname, port=port, username=username, password=password, quick=quick)
def begin(self): # The tests require that the environment is currently set to en_US, to avoid # translated strings and use the default date/number/currency formatting from stoqlib.lib.environment import configure_locale configure_locale('en_US') # FIXME python3: # This is to make our usage of contextlib.nested compatible for now @contextlib.contextmanager def _nested(*ctxs): with contextlib.ExitStack() as stack: yield tuple(stack.enter_context(ctx) for ctx in ctxs) contextlib.nested = _nested # If we import tests.base before Cover.setup() in the coverage plugin # is called the statistics will skip the modules imported by tests.base from stoqlib.database.testsuite import bootstrap_suite hostname = os.environ.get('STOQLIB_TEST_HOSTNAME') dbname = os.environ.get('STOQLIB_TEST_DBNAME') username = os.environ.get('STOQLIB_TEST_USERNAME') password = os.environ.get('STOQLIB_TEST_PASSWORD') port = int(os.environ.get('STOQLIB_TEST_PORT') or 0) quick = os.environ.get('STOQLIB_TEST_QUICK', None) is not None config = os.path.join( os.path.dirname(stoqlib.__file__), 'tests', 'config.py') if os.path.exists(config): exec(compile(open(config).read(), config, 'exec'), globals(), locals()) bootstrap_suite(address=hostname, dbname=dbname, port=port, username=username, password=password, quick=quick)
def _setup_test_environment(request): plugin_config = _get_plugin_configs(request.config) if plugin_config['skip_env_setup']: return stoq_config = StoqConfig() stoq_config.load_default() register_config(stoq_config) quick = plugin_config['quick_mode'] or _to_falsy( os.environ.get("STOQLIB_TEST_QUICK", None)) bootstrap_suite( address=os.environ.get("STOQLIB_TEST_HOSTNAME"), dbname=os.environ.get("STOQLIB_TEST_DBNAME"), port=int(os.environ.get("STOQLIB_TEST_PORT") or 0), username=os.environ.get("STOQLIB_TEST_USERNAME"), password=os.environ.get("STOQLIB_TEST_PASSWORD"), quick=quick, ) manager = get_plugin_manager() for plugin_name in plugin_config['extra_plugins']: _register_plugin(plugin_name) with stoqlib.api.new_store() as store: manager.install_plugin(store, plugin_name) manager.activate_plugin(plugin_name) plugin_cls = plugin_config['plugin_cls'] if plugin_cls: _install_plugin(plugin_cls)
def begin(self): # The tests require that the environment is currently set to C, to avoid # translated strings and use the default date/number/currency formatting os.environ['LC_ALL'] = 'C' os.environ['LANG'] = 'C' os.environ['LANGUAGE'] = 'C' if 'STOQ_USE_GI' in os.environ: from stoq.lib import gicompat gicompat.enable() # If we import tests.base before Cover.setup() in the coverage plugin # is called the statistics will skip the modules imported by tests.base from stoqlib.database.testsuite import bootstrap_suite hostname = os.environ.get('STOQLIB_TEST_HOSTNAME') dbname = os.environ.get('STOQLIB_TEST_DBNAME') username = os.environ.get('STOQLIB_TEST_USERNAME') password = os.environ.get('STOQLIB_TEST_PASSWORD') port = int(os.environ.get('STOQLIB_TEST_PORT') or 0) quick = os.environ.get('STOQLIB_TEST_QUICK', None) is not None config = os.path.join(os.path.dirname(stoqlib.__file__), 'tests', 'config.py') if os.path.exists(config): execfile(config, globals(), locals()) bootstrap_suite(address=hostname, dbname=dbname, port=port, username=username, password=password, quick=quick)
## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., or visit: http://www.gnu.org/. ## ## Author(s): Stoq Team <*****@*****.**> ## """ Base module to be used by all domain test modules""" import os from stoqlib.database.testsuite import bootstrap_suite hostname = os.environ.get('STOQLIB_TEST_HOSTNAME') dbname = os.environ.get('STOQLIB_TEST_DBNAME') username = os.environ.get('STOQLIB_TEST_USERNAME') password = os.environ.get('STOQLIB_TEST_PASSWORD') port = int(os.environ.get('STOQLIB_TEST_PORT') or 0) quick = os.environ.get('STOQLIB_TEST_QUICK', None) is not None config = os.path.join(os.path.dirname(__file__), 'config.py') if os.path.exists(config): execfile(config, globals(), locals()) bootstrap_suite(address=hostname, dbname=dbname, port=port, username=username, password=password, quick=quick)