Skip to content

Commit 95a4cca

Browse files
committed
document tests
1 parent 00fc23d commit 95a4cca

File tree

1 file changed

+46
-2
lines changed

1 file changed

+46
-2
lines changed

tests/test_function_plotter.py

+46-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212

1313
@pytest.fixture(scope="session")
1414
def app_instance():
15-
"""Fixture for creating a QApplication instance."""
15+
"""
16+
Fixture for creating a QApplication instance.
17+
18+
Returns:
19+
- QApplication: The QApplication instance.
20+
"""
1621
app = QApplication.instance()
1722
if app is None:
1823
app = QApplication([])
@@ -21,7 +26,16 @@ def app_instance():
2126

2227
@pytest.fixture
2328
def function_plotter(app_instance, qtbot):
24-
"""Fixture for creating a FunctionPlotter instance."""
29+
"""
30+
Fixture for creating a FunctionPlotter instance.
31+
32+
Parameters:
33+
- app_instance (QApplication): The QApplication instance.
34+
- qtbot (QtBot): The QtBot instance for simulating user interactions.
35+
36+
Returns:
37+
- FunctionPlotter: The FunctionPlotter instance.
38+
"""
2539
plotter = FunctionPlotter()
2640
qtbot.addWidget(plotter)
2741
return plotter
@@ -31,6 +45,9 @@ def function_plotter(app_instance, qtbot):
3145

3246

3347
def test_valid_function_input(function_plotter, qtbot):
48+
"""
49+
Test plotting a valid function.
50+
"""
3451
function_plotter.function_input.setText("5*x^3 + 2*x")
3552
function_plotter.min_input.setText("0")
3653
function_plotter.max_input.setText("10")
@@ -39,6 +56,9 @@ def test_valid_function_input(function_plotter, qtbot):
3956

4057

4158
def test_function_with_logarithm(function_plotter, qtbot):
59+
"""
60+
Test plotting a function with a logarithm.
61+
"""
4262
function_plotter.function_input.setText("log10(x)")
4363
function_plotter.min_input.setText("1")
4464
function_plotter.max_input.setText("100")
@@ -47,6 +67,9 @@ def test_function_with_logarithm(function_plotter, qtbot):
4767

4868

4969
def test_function_with_square_root(function_plotter, qtbot):
70+
"""
71+
Test plotting a function with a square root.
72+
"""
5073
function_plotter.function_input.setText("sqrt(x)")
5174
function_plotter.min_input.setText("0")
5275
function_plotter.max_input.setText("25")
@@ -55,6 +78,9 @@ def test_function_with_square_root(function_plotter, qtbot):
5578

5679

5780
def test_function_with_combined_operators(function_plotter, qtbot):
81+
"""
82+
Test plotting a function with combined operators.
83+
"""
5884
function_plotter.function_input.setText("sqrt(x) + log10(x) + x^2")
5985
function_plotter.min_input.setText("1")
6086
function_plotter.max_input.setText("10")
@@ -63,6 +89,9 @@ def test_function_with_combined_operators(function_plotter, qtbot):
6389

6490

6591
def test_large_range_of_x(function_plotter, qtbot):
92+
"""
93+
Test plotting a function over a large range of x values.
94+
"""
6695
function_plotter.function_input.setText("x^2")
6796
function_plotter.min_input.setText("-1000")
6897
function_plotter.max_input.setText("1000")
@@ -71,6 +100,9 @@ def test_large_range_of_x(function_plotter, qtbot):
71100

72101

73102
def test_small_range_of_x(function_plotter, qtbot):
103+
"""
104+
Test plotting a function over a small range of x values.
105+
"""
74106
function_plotter.function_input.setText("x^2")
75107
function_plotter.min_input.setText("0")
76108
function_plotter.max_input.setText("1")
@@ -79,6 +111,9 @@ def test_small_range_of_x(function_plotter, qtbot):
79111

80112

81113
def test_negative_x_values(function_plotter, qtbot):
114+
"""
115+
Test plotting a function with negative x values.
116+
"""
82117
function_plotter.function_input.setText("x^3")
83118
function_plotter.min_input.setText("-10")
84119
function_plotter.max_input.setText("0")
@@ -87,6 +122,9 @@ def test_negative_x_values(function_plotter, qtbot):
87122

88123

89124
def test_high_degree_polynomial(function_plotter, qtbot):
125+
"""
126+
Test plotting a high-degree polynomial function.
127+
"""
90128
function_plotter.function_input.setText("x^6 - 2*x^4 + x^2")
91129
function_plotter.min_input.setText("-10")
92130
function_plotter.max_input.setText("10")
@@ -95,6 +133,9 @@ def test_high_degree_polynomial(function_plotter, qtbot):
95133

96134

97135
def test_floating_point_coefficients(function_plotter, qtbot):
136+
"""
137+
Test floating point coefficients function.
138+
"""
98139
function_plotter.function_input.setText("0.5*x^2 + 2.5*x")
99140
function_plotter.min_input.setText("-5")
100141
function_plotter.max_input.setText("5")
@@ -103,6 +144,9 @@ def test_floating_point_coefficients(function_plotter, qtbot):
103144

104145

105146
def test_function_with_spaces(function_plotter, qtbot):
147+
"""
148+
Test function with spaces.
149+
"""
106150
function_plotter.function_input.setText(" x ^ 2 + 3 * x ")
107151
function_plotter.min_input.setText("-5")
108152
function_plotter.max_input.setText("5")

0 commit comments

Comments
 (0)