tests: added special no-newline test name generator

This commit is contained in:
Marcin Kuzminski 2017-04-27 21:37:53 +02:00
parent dfec9d48a2
commit 196813bfdd

View file

@ -56,7 +56,7 @@ log = logging.getLogger(__name__)
__all__ = [
'get_new_dir', 'TestController', 'SkipTest',
'url', 'link_to', 'ldap_lib_installed', 'clear_all_caches',
'assert_session_flash', 'login_user',
'assert_session_flash', 'login_user', 'no_newline_id_generator',
'TESTS_TMP_PATH', 'HG_REPO', 'GIT_REPO', 'SVN_REPO',
'NEW_HG_REPO', 'NEW_GIT_REPO',
'HG_FORK', 'GIT_FORK', 'TEST_USER_ADMIN_LOGIN', 'TEST_USER_ADMIN_PASS',
@ -249,3 +249,17 @@ def assert_session_flash_is_empty(response):
msg = 'flash messages are present in session:%s' % \
response.session['flash'][0]
pytest.fail(safe_str(msg))
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
test_name = test_name\
.replace('\n', '_N') \
.replace('\t', '_T') \
.replace(' ', '_S')
return test_name or 'test-with-empty-name'