Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Add test for file directory change in the Project Explorer. #6413

Merged
merged 8 commits into from
Feb 15, 2018
38 changes: 38 additions & 0 deletions spyder/app/tests/test_mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,44 @@ def test_calltip(main_window, qtbot):
main_window.editor.close_file()


@pytest.mark.slow
@flaky(max_runs=3)
def test_change_directory_in_project_explorer(main_window, qtbot, tmpdir):
Copy link
Member

@ccordoba12 ccordoba12 Feb 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test doesn't need to interact with other plugins (e.g. the IPython console), so it doesn't belong here. Please move it to spyder/plugins/tests/test_projects.py.

"""Test changing a file from directory in the Project explorer."""
projects = main_window.projects

# Create a temp project directory
project_dir = str(tmpdir.mkdir('project'))
project_dir_tmp = osp.join(project_dir, 'tmpá')

# Create an empty file in the project dir
project_file = osp.join(LOCATION, 'script.py')
shutil.copy(project_file, osp.join(project_dir, 'script.py'))
os.mkdir(project_dir_tmp)

# Create project
with qtbot.waitSignal(projects.sig_project_loaded):
projects._create_project(project_dir)

# Select file in the project explorer
idx = projects.treewidget.get_index('script.py')
projects.treewidget.setCurrentIndex(idx)

# Set a timer to manipulate the select directory dialog while it's running
QTimer.singleShot(2000, lambda: open_file_in_editor(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this timer is what's making the test to hang on Appveyor.

main_window,
'',
directory=project_dir_tmp))
# Move Python file
projects.treewidget.move(fnames=[osp.join(project_dir, 'script.py')])

# Assert content was moved
assert osp.isfile(osp.join(project_dir_tmp, 'script.py'))

# Close project
projects.close_project()


@pytest.mark.slow
@pytest.mark.single_instance
def test_single_instance_and_edit_magic(main_window, qtbot, tmpdir):
Expand Down