From 55bb6a35cf57e124e36fe681f523359f3695e0ab Mon Sep 17 00:00:00 2001 From: Lukas Klenk Date: Thu, 24 Mar 2022 09:12:46 +0000 Subject: [PATCH] Change to is None and create strings with %s --- tests/test_utils/test_regex.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/test_utils/test_regex.py b/tests/test_utils/test_regex.py index 4b08d4e..bce6ccb 100644 --- a/tests/test_utils/test_regex.py +++ b/tests/test_utils/test_regex.py @@ -7,63 +7,63 @@ from pysnooper.tracer import ansible_filename_pattern def test_ansible_filename_pattern(): archive_file = '/tmp/ansible_my_module_payload_xyz1234/ansible_my_module_payload.zip' source_code_file = 'ansible/modules/my_module.py' - file_name = archive_file + '/' + source_code_file + file_name = '%s/%s' % (archive_file, source_code_file) assert ansible_filename_pattern.match(file_name).group(1) == archive_file assert ansible_filename_pattern.match(file_name).group(2) == source_code_file archive_file = '/tmp/ansible_my_module_payload_xyz1234/ansible_my_module_with.zip_name.zip' source_code_file = 'ansible/modules/my_module.py' - file_name = archive_file + '/' + source_code_file + file_name = '%s/%s' % (archive_file, source_code_file) assert ansible_filename_pattern.match(file_name).group(1) == archive_file assert ansible_filename_pattern.match(file_name).group(2) == source_code_file archive_file = '/my/new/path/payload.zip' source_code_file = 'ansible/modules/my_module.py' - file_name = archive_file + '/' + source_code_file + file_name = '%s/%s' % (archive_file, source_code_file) assert ansible_filename_pattern.match(file_name).group(1) == archive_file assert ansible_filename_pattern.match(file_name).group(2) == source_code_file archive_file = '/tmp/ansible_my_module_payload_xyz1234/ansible_my_module_payload.zip' source_code_file = 'ansible/modules/in/new/path/my_module.py' - file_name = archive_file + '/' + source_code_file + file_name = '%s/%s' % (archive_file, source_code_file) assert ansible_filename_pattern.match(file_name).group(1) == archive_file assert ansible_filename_pattern.match(file_name).group(2) == source_code_file archive_file = '/tmp/ansible_my_module_payload_xyz1234/ansible_my_module_payload.zip' source_code_file = 'ansible/modules/my_module_is_called_.py.py' - file_name = archive_file + '/' + source_code_file + file_name = '%s/%s' % (archive_file, source_code_file) assert ansible_filename_pattern.match(file_name).group(1) == archive_file assert ansible_filename_pattern.match(file_name).group(2) == source_code_file archive_file = '/tmp/ansible_my_module_payload_xyz1234/ansible_my_module_payload.zip' source_code_file = 'ANSIBLE/modules/my_module.py' - file_name = archive_file + '/' + source_code_file - assert ansible_filename_pattern.match(file_name) == None + file_name = '%s/%s' % (archive_file, source_code_file) + assert ansible_filename_pattern.match(file_name) is None archive_file = '/tmp/ansible_my_module_payload_xyz1234/ansible_my_module_payload.zip' source_code_file = 'ansible/modules/my_module.PY' - file_name = archive_file + '/' + source_code_file - assert ansible_filename_pattern.match(file_name) == None + file_name = '%s/%s' % (archive_file, source_code_file) + assert ansible_filename_pattern.match(file_name) is None archive_file = '/tmp/ansible_my_module_payload_xyz1234/ansible_my_module_payload.Zip' source_code_file = 'ansible/modules/my_module.py' - file_name = archive_file + '/' + source_code_file - assert ansible_filename_pattern.match(file_name) == None + file_name = '%s/%s' % (archive_file, source_code_file) + assert ansible_filename_pattern.match(file_name) is None archive_file = '/tmp/ansible_my_module_payload_xyz1234/ansible_my_module_payload.zip' source_code_file = 'ansible/my_module.py' - file_name = archive_file + '/' + source_code_file - assert ansible_filename_pattern.match(file_name) == None + file_name = '%s/%s' % (archive_file, source_code_file) + assert ansible_filename_pattern.match(file_name) is None archive_file = '/tmp/ansible_my_module_payload_xyz1234/ansible_my_module_payload.zip' source_code_file = '' - file_name = archive_file + '/' + source_code_file - assert ansible_filename_pattern.match(file_name) == None + file_name = '%s/%s' % (archive_file, source_code_file) + assert ansible_filename_pattern.match(file_name) is None archive_file = '' source_code_file = 'ansible/modules/my_module.py' - file_name = archive_file + '/' + source_code_file - assert ansible_filename_pattern.match(file_name) == None + file_name = '%s/%s' % (archive_file, source_code_file) + assert ansible_filename_pattern.match(file_name) is None