tests(core): made the test flag setting more flexible.

We no longer use .ini setting, but relly on env variables, that is now set
via pytest env plugin
This commit is contained in:
RhodeCode Admin 2024-03-11 09:56:10 +01:00
parent ca042238f9
commit 7f994fc993
6 changed files with 13 additions and 6 deletions

View file

@ -21,3 +21,7 @@ markers =
skip_backends: Mark tests as skipped for given backends.
backends: Mark backends
dbs: database markers for running tests for given DB
env =
RC_TEST=1
RUN_ENV=test

View file

@ -11,6 +11,12 @@ pytest-cov==4.0.0
iniconfig==2.0.0
packaging==23.1
pluggy==1.0.0
pytest-env==1.1.3
pytest==7.3.1
attrs==22.2.0
iniconfig==2.0.0
packaging==23.1
pluggy==1.0.0
pytest-rerunfailures==12.0
pytest-profiling==1.7.0
gprof2dot==2022.7.29

View file

@ -87,5 +87,5 @@ __license__ = 'AGPLv3, and Commercial License'
__author__ = 'RhodeCode GmbH'
__url__ = 'https://code.rhodecode.com'
is_test = False
is_test = os.getenv('RC_TEST')
disable_error_handler = False

View file

@ -92,7 +92,6 @@ def sanitize_settings_and_apply_defaults(global_config, settings):
# Sanitize generic settings.
settings_maker.make_setting('default_encoding', 'UTF-8', parser='list')
settings_maker.make_setting('is_test', False, parser='bool')
settings_maker.make_setting('gzip_responses', False, parser='bool')
settings_maker.make_setting('startup.import_repos', 'false', parser='bool')

View file

@ -46,8 +46,7 @@ def load_pyramid_environment(global_config, settings):
# If this is a test run we prepare the test environment like
# creating a test database, test search index and test repositories.
# This has to be done before the database connection is initialized.
if settings['is_test']:
rhodecode.is_test = True
if rhodecode.is_test:
rhodecode.disable_error_handler = True
from rhodecode import authentication
authentication.plugin_default_auth_ttl = 0

View file

@ -86,8 +86,7 @@ class DBBackend(object):
_store = os.path.dirname(os.path.abspath(__file__))
_type = None
_base_ini_config = [{'app:main': {'vcs.start_server': 'false',
'startup.import_repos': 'false',
'is_test': 'False'}}]
'startup.import_repos': 'false'}}]
_db_url = [{'app:main': {'sqlalchemy.db1.url': ''}}]
_base_db_name = 'rhodecode_test_db_backend'