From 6696a9914ed4ea85630155449f88ea973aca1080 Mon Sep 17 00:00:00 2001 From: Julian Gilbey Date: Fri, 12 Jan 2024 06:38:44 +0000 Subject: [PATCH] Fix test_renamed_tree for Windows systems --- spyder/plugins/editor/tests/test_plugin.py | 41 +++++++++++++++------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/spyder/plugins/editor/tests/test_plugin.py b/spyder/plugins/editor/tests/test_plugin.py index d71adec7308..040f93592d7 100644 --- a/spyder/plugins/editor/tests/test_plugin.py +++ b/spyder/plugins/editor/tests/test_plugin.py @@ -136,19 +136,36 @@ def test_renamed_tree(editor_plugin, mocker): editor = editor_plugin mocker.patch.object(editor, 'get_filenames') mocker.patch.object(editor, 'renamed') - editor.get_filenames.return_value = ['/test/directory/file1.py', - '/test/directory/file2.txt', - '/home/spyder/testing/file3.py', - '/test/directory/file4.rst'] - - editor.renamed_tree('/test/directory', '/test/dir') + if os.name == "nt": + filenames = [r'C:\test\directory\file1.py', + r'C:\test\directory\file2.txt', + r'C:\home\spyder\testing\file3.py', + r'C:\test\directory\file4.rst'] + expected = [r'C:\test\dir\file1.py', + r'C:\test\dir\file2.txt', + r'C:\home\spyder\testing\file3.py', + r'C:\test\dir\file4.rst'] + sourcedir = r'C:\test\directory' + destdir = r'C:\test\dir' + else: + filenames = ['/test/directory/file1.py', + '/test/directory/file2.txt', + '/home/spyder/testing/file3.py', + '/test/directory/file4.rst'] + expected = ['/test/dir/file1.py', + '/test/dir/file2.txt', + '/home/spyder/testing/file3.py', + '/test/dir/file4.rst'] + sourcedir = '/test/directory' + destdir = '/test/dir' + + editor.get_filenames.return_value = filenames + + editor.renamed_tree(sourcedir, destdir) assert editor.renamed.call_count == 3 - editor.renamed.assert_any_call(source='/test/directory/file1.py', - dest='/test/dir/file1.py') - editor.renamed.assert_any_call(source='/test/directory/file2.txt', - dest='/test/dir/file2.txt') - editor.renamed.assert_any_call(source='/test/directory/file4.rst', - dest='/test/dir/file4.rst') + for file in [0, 1, 3]: + editor.renamed.assert_any_call(source=filenames[file], + dest=expected[file]) def test_no_template(editor_plugin):