Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c167ec6

Browse files
update tests
1 parent ac90160 commit c167ec6

File tree

1 file changed

+56
-2
lines changed

1 file changed

+56
-2
lines changed

‎tests/test_function_plotter.py

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ def function_plotter(app_instance, qtbot):
2727
return plotter
2828

2929

30+
# good input tests
31+
32+
3033
def test_valid_function_input(function_plotter, qtbot):
3134
function_plotter.function_input.setText("5*x^3 + 2*x")
3235
function_plotter.min_input.setText("0")
@@ -99,11 +102,62 @@ def test_floating_point_coefficients(function_plotter, qtbot):
99102
assert function_plotter.ax.has_data()
100103

101104

102-
103-
104105
def test_function_with_spaces(function_plotter, qtbot):
105106
function_plotter.function_input.setText(" x ^ 2 + 3 * x ")
106107
function_plotter.min_input.setText("-5")
107108
function_plotter.max_input.setText("5")
108109
qtbot.mouseClick(function_plotter.plot_button, Qt.LeftButton)
109110
assert function_plotter.ax.has_data()
111+
112+
113+
# bad input tests
114+
115+
116+
# def test_invalid_function_input_characters(function_plotter, qtbot):
117+
# function_plotter.function_input.setText("5*x^3 + 2*x + !")
118+
# function_plotter.min_input.setText("0")
119+
# function_plotter.max_input.setText("10")
120+
# qtbot.mouseClick(function_plotter.plot_button, Qt.LeftButton)
121+
# qtbot.waitUntil(lambda: function_plotter.centralWidget().findChildren(QMessageBox))
122+
# message_box = function_plotter.centralWidget().findChildren(QMessageBox)[0]
123+
# assert "Function contains invalid characters." in message_box.text()
124+
125+
126+
# def test_empty_function_input(function_plotter, qtbot):
127+
# function_plotter.function_input.setText("")
128+
# function_plotter.min_input.setText("0")
129+
# function_plotter.max_input.setText("10")
130+
# qtbot.mouseClick(function_plotter.plot_button, Qt.LeftButton)
131+
# qtbot.waitUntil(lambda: function_plotter.centralWidget().findChildren(QMessageBox))
132+
# message_box = function_plotter.centralWidget().findChildren(QMessageBox)[0]
133+
# assert "Function cannot be empty." in message_box.text()
134+
135+
136+
# def test_invalid_min_max_values(function_plotter, qtbot):
137+
# function_plotter.function_input.setText("5*x^3 + 2*x")
138+
# function_plotter.min_input.setText("10")
139+
# function_plotter.max_input.setText("0")
140+
# qtbot.mouseClick(function_plotter.plot_button, Qt.LeftButton)
141+
# qtbot.waitUntil(lambda: function_plotter.centralWidget().findChildren(QMessageBox))
142+
# message_box = function_plotter.centralWidget().findChildren(QMessageBox)[0]
143+
# assert "Min value must be less than Max value." in message_box.text()
144+
145+
146+
# def test_non_numeric_min_max_values(function_plotter, qtbot):
147+
# function_plotter.function_input.setText("5*x^3 + 2*x")
148+
# function_plotter.min_input.setText("a")
149+
# function_plotter.max_input.setText("b")
150+
# qtbot.mouseClick(function_plotter.plot_button, Qt.LeftButton)
151+
# qtbot.waitUntil(lambda: function_plotter.centralWidget().findChildren(QMessageBox))
152+
# message_box = function_plotter.centralWidget().findChildren(QMessageBox)[0]
153+
# assert "Min and Max values must be numbers." in message_box.text()
154+
155+
156+
# def test_empty_min_max_values(function_plotter, qtbot):
157+
# function_plotter.function_input.setText("x^2")
158+
# function_plotter.min_input.setText("")
159+
# function_plotter.max_input.setText("")
160+
# qtbot.mouseClick(function_plotter.plot_button, Qt.LeftButton)
161+
# qtbot.waitUntil(lambda: function_plotter.centralWidget().findChildren(QMessageBox))
162+
# message_box = function_plotter.centralWidget().findChildren(QMessageBox)[0]
163+
# assert "Min and Max values cannot be empty." in message_box.text()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /