12
12
13
13
@pytest .fixture (scope = "session" )
14
14
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
+ """
16
21
app = QApplication .instance ()
17
22
if app is None :
18
23
app = QApplication ([])
@@ -21,7 +26,16 @@ def app_instance():
21
26
22
27
@pytest .fixture
23
28
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
+ """
25
39
plotter = FunctionPlotter ()
26
40
qtbot .addWidget (plotter )
27
41
return plotter
@@ -31,6 +45,9 @@ def function_plotter(app_instance, qtbot):
31
45
32
46
33
47
def test_valid_function_input (function_plotter , qtbot ):
48
+ """
49
+ Test plotting a valid function.
50
+ """
34
51
function_plotter .function_input .setText ("5*x^3 + 2*x" )
35
52
function_plotter .min_input .setText ("0" )
36
53
function_plotter .max_input .setText ("10" )
@@ -39,6 +56,9 @@ def test_valid_function_input(function_plotter, qtbot):
39
56
40
57
41
58
def test_function_with_logarithm (function_plotter , qtbot ):
59
+ """
60
+ Test plotting a function with a logarithm.
61
+ """
42
62
function_plotter .function_input .setText ("log10(x)" )
43
63
function_plotter .min_input .setText ("1" )
44
64
function_plotter .max_input .setText ("100" )
@@ -47,6 +67,9 @@ def test_function_with_logarithm(function_plotter, qtbot):
47
67
48
68
49
69
def test_function_with_square_root (function_plotter , qtbot ):
70
+ """
71
+ Test plotting a function with a square root.
72
+ """
50
73
function_plotter .function_input .setText ("sqrt(x)" )
51
74
function_plotter .min_input .setText ("0" )
52
75
function_plotter .max_input .setText ("25" )
@@ -55,6 +78,9 @@ def test_function_with_square_root(function_plotter, qtbot):
55
78
56
79
57
80
def test_function_with_combined_operators (function_plotter , qtbot ):
81
+ """
82
+ Test plotting a function with combined operators.
83
+ """
58
84
function_plotter .function_input .setText ("sqrt(x) + log10(x) + x^2" )
59
85
function_plotter .min_input .setText ("1" )
60
86
function_plotter .max_input .setText ("10" )
@@ -63,6 +89,9 @@ def test_function_with_combined_operators(function_plotter, qtbot):
63
89
64
90
65
91
def test_large_range_of_x (function_plotter , qtbot ):
92
+ """
93
+ Test plotting a function over a large range of x values.
94
+ """
66
95
function_plotter .function_input .setText ("x^2" )
67
96
function_plotter .min_input .setText ("-1000" )
68
97
function_plotter .max_input .setText ("1000" )
@@ -71,6 +100,9 @@ def test_large_range_of_x(function_plotter, qtbot):
71
100
72
101
73
102
def test_small_range_of_x (function_plotter , qtbot ):
103
+ """
104
+ Test plotting a function over a small range of x values.
105
+ """
74
106
function_plotter .function_input .setText ("x^2" )
75
107
function_plotter .min_input .setText ("0" )
76
108
function_plotter .max_input .setText ("1" )
@@ -79,6 +111,9 @@ def test_small_range_of_x(function_plotter, qtbot):
79
111
80
112
81
113
def test_negative_x_values (function_plotter , qtbot ):
114
+ """
115
+ Test plotting a function with negative x values.
116
+ """
82
117
function_plotter .function_input .setText ("x^3" )
83
118
function_plotter .min_input .setText ("-10" )
84
119
function_plotter .max_input .setText ("0" )
@@ -87,6 +122,9 @@ def test_negative_x_values(function_plotter, qtbot):
87
122
88
123
89
124
def test_high_degree_polynomial (function_plotter , qtbot ):
125
+ """
126
+ Test plotting a high-degree polynomial function.
127
+ """
90
128
function_plotter .function_input .setText ("x^6 - 2*x^4 + x^2" )
91
129
function_plotter .min_input .setText ("-10" )
92
130
function_plotter .max_input .setText ("10" )
@@ -95,6 +133,9 @@ def test_high_degree_polynomial(function_plotter, qtbot):
95
133
96
134
97
135
def test_floating_point_coefficients (function_plotter , qtbot ):
136
+ """
137
+ Test floating point coefficients function.
138
+ """
98
139
function_plotter .function_input .setText ("0.5*x^2 + 2.5*x" )
99
140
function_plotter .min_input .setText ("-5" )
100
141
function_plotter .max_input .setText ("5" )
@@ -103,6 +144,9 @@ def test_floating_point_coefficients(function_plotter, qtbot):
103
144
104
145
105
146
def test_function_with_spaces (function_plotter , qtbot ):
147
+ """
148
+ Test function with spaces.
149
+ """
106
150
function_plotter .function_input .setText (" x ^ 2 + 3 * x " )
107
151
function_plotter .min_input .setText ("-5" )
108
152
function_plotter .max_input .setText ("5" )
0 commit comments