Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
c7fbd821
Commit
c7fbd821
authored
4 years ago
by
Joseph Torsney
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for workbench.util.io
parent
1475aa3b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
qt/applications/workbench/workbench/utils/test/test_io.py
+43
-0
43 additions, 0 deletions
qt/applications/workbench/workbench/utils/test/test_io.py
with
43 additions
and
0 deletions
qt/applications/workbench/workbench/utils/test/test_io.py
0 → 100644
+
43
−
0
View file @
c7fbd821
# Mantid Repository : https://github.com/mantidproject/mantid
#
# Copyright © 2021 ISIS Rutherford Appleton Laboratory UKRI,
# NScD Oak Ridge National Laboratory, European Spallation Source,
# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
# SPDX - License - Identifier: GPL - 3.0 +
# This file is part of the mantidworkbench package
from
unittest
import
TestCase
from
unittest.mock
import
patch
from
PyQt5.QtWidgets
import
QInputDialog
from
workbench.utils.io
import
input_qinputdialog
class
IOTest
(
TestCase
):
@patch
(
'
workbench.utils.io.QInputDialog
'
)
def
test_input_qinputdialog_setup_is_correct
(
self
,
mock_QInputDialogClass
):
mock_QInputDialogClass
.
TextInput
=
QInputDialog
.
TextInput
mock_QInputDialog
=
mock_QInputDialogClass
()
_
=
input_qinputdialog
(
"
prompt
"
)
mock_QInputDialog
.
setInputMode
.
assert_called_with
(
QInputDialog
.
TextInput
)
mock_QInputDialog
.
setLabelText
.
assert_called_with
(
"
prompt
"
)
@patch
(
'
workbench.utils.io.QInputDialog
'
)
def
test_input_qinputdialog_return_value_is_correct_when_dialog_accepted
(
self
,
mock_QInputDialogClass
):
mock_QInputDialog
=
mock_QInputDialogClass
()
mock_QInputDialog
.
exec_
.
return_value
=
True
mock_QInputDialog
.
textValue
.
return_value
=
"
their input
"
user_input
=
input_qinputdialog
()
self
.
assertEqual
(
user_input
,
"
their input
"
)
@patch
(
'
workbench.utils.io.QInputDialog
'
)
def
test_input_qinputdialog_raises_RuntimeError_when_input_cancelled
(
self
,
mock_QInputDialogClass
):
mock_QInputDialog
=
mock_QInputDialogClass
()
mock_QInputDialog
.
exec_
.
return_value
=
False
self
.
assertRaises
(
RuntimeError
,
input_qinputdialog
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment