-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
+57
−13
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b5842ac
Add test for file directory change in the Project Explorer.
dalthviz a158168
Testing
dalthviz 80c5ab1
Change directory implementation to handle a specified dir.
dalthviz a33c150
Remove unnecessary function for the testing.
dalthviz 8d00a9f
Testing.
dalthviz 84f79f7
Correct use of the fixture in project explorer tests.
dalthviz 1c7153e
Make directory an attributte of the ProjectExplorerTest class.
dalthviz f6983b2
Change directory in the test.
dalthviz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,6 +73,18 @@ | |
# ============================================================================= | ||
# Utility functions | ||
# ============================================================================= | ||
|
||
|
||
def select_directory(main_window, directory=None): | ||
"""Open a file using the Editor and its open file dialog""" | ||
top_level_widgets = QApplication.topLevelWidgets() | ||
for w in top_level_widgets: | ||
if isinstance(w, QFileDialog): | ||
if directory is not None: | ||
w.setDirectory(directory) | ||
QTest.keyClick(w, Qt.Key_Enter) | ||
|
||
|
||
def open_file_in_editor(main_window, fname, directory=None): | ||
"""Open a file using the Editor and its open file dialog""" | ||
top_level_widgets = QApplication.topLevelWidgets() | ||
|
@@ -205,6 +217,40 @@ 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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
"""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) | ||
|
||
# Move Python file | ||
projects.treewidget.move(fnames=[osp.join(project_dir, 'script.py')], | ||
directory=project_dir_tmp) | ||
|
||
# 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): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This auxiliary function is not needed anymore. Please remove it.