##// END OF EJS Templates
chore(deps): bumped mercurial to 6.7.4, hg-evolve to 11.1.3, fixed related issues
chore(deps): bumped mercurial to 6.7.4, hg-evolve to 11.1.3, fixed related issues

File last commit:

r1152:a0c49580 default
r1248:8cfec191 default
Show More
fixture.py
85 lines | 3.0 KiB | text/x-python | PythonLexer
packaging: moved tests into the main library itself. This is consistent with how our other projects do it.
r130 # RhodeCode VCSServer provides access to different vcs backends via network.
source-code: updated copyrights to 2023
r1126 # Copyright (C) 2014-2023 RhodeCode GmbH
packaging: moved tests into the main library itself. This is consistent with how our other projects do it.
r130 #
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import os
import shutil
import tempfile
core: dropped configobj package use
r1065 import configparser
packaging: moved tests into the main library itself. This is consistent with how our other projects do it.
r130
lint: auto-fixes
r1152 class ContextINI:
packaging: moved tests into the main library itself. This is consistent with how our other projects do it.
r130 """
Allows to create a new test.ini file as a copy of existing one with edited
data. If existing file is not present, it creates a new one. Example usage::
with TestINI('test.ini', [{'section': {'key': 'val'}}]) as new_test_ini_path:
print 'vcsserver --config=%s' % new_test_ini
"""
def __init__(self, ini_file_path, ini_params, new_file_prefix=None,
destroy=True):
self.ini_file_path = ini_file_path
self.ini_params = ini_params
self.new_path = None
self.new_path_prefix = new_file_prefix or 'test'
self.destroy = destroy
def __enter__(self):
_, pref = tempfile.mkstemp()
loc = tempfile.gettempdir()
self.new_path = os.path.join(loc, '{}_{}_{}'.format(
pref, self.new_path_prefix, self.ini_file_path))
# copy ini file and modify according to the params, if we re-use a file
if os.path.isfile(self.ini_file_path):
shutil.copy(self.ini_file_path, self.new_path)
else:
# create new dump file for configObj to write to.
with open(self.new_path, 'wb'):
pass
core: dropped configobj package use
r1065 parser = configparser.ConfigParser()
parser.read(self.ini_file_path)
packaging: moved tests into the main library itself. This is consistent with how our other projects do it.
r130
for data in self.ini_params:
python3: another 2to3 pass
r1054 section, ini_params = list(data.items())[0]
key, val = list(ini_params.items())[0]
core: dropped configobj package use
r1065 if section not in parser:
parser[section] = {}
parser[section][key] = val
with open(self.ini_file_path, 'w') as f:
parser.write(f)
packaging: moved tests into the main library itself. This is consistent with how our other projects do it.
r130 return self.new_path
def __exit__(self, exc_type, exc_val, exc_tb):
if self.destroy:
os.remove(self.new_path)
svn: added support for hooks management of git and subversion....
r407
def no_newline_id_generator(test_name):
"""
Generates a test name without spaces or newlines characters. Used for
nicer output of progress of test
"""
org_name = test_name
hooks: store hook type for extensions.
r555 test_name = str(test_name)\
svn: added support for hooks management of git and subversion....
r407 .replace('\n', '_N') \
.replace('\r', '_N') \
.replace('\t', '_T') \
.replace(' ', '_S')
return test_name or 'test-with-empty-name'