Skip to content

Commit

Permalink
Fix test_renamed_tree for Windows systems
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Gilbey committed Jan 12, 2024
1 parent e20df10 commit 6696a99
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions spyder/plugins/editor/tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 6696a99

Please sign in to comment.