54
54
}
55
55
56
56
57
- class BaseFastAPI :
57
+ class TestBaseFastAPI ( TestBase ) :
58
58
def _create_app (self ):
59
59
app = self ._create_fastapi_app ()
60
60
self ._instrumentor .instrument_app (
@@ -77,6 +77,15 @@ def _create_app_explicit_excluded_urls(self):
77
77
)
78
78
return app
79
79
80
+ @classmethod
81
+ def setUpClass (cls ):
82
+ if cls is TestBaseFastAPI :
83
+ raise unittest .SkipTest (
84
+ f"{ cls .__name__ } is an abstract base class"
85
+ )
86
+
87
+ super (TestBaseFastAPI , cls ).setUpClass ()
88
+
80
89
def setUp (self ):
81
90
super ().setUp ()
82
91
self .env_patch = patch .dict (
@@ -132,7 +141,16 @@ async def _():
132
141
return app
133
142
134
143
135
- class BaseManualFastAPI (BaseFastAPI ):
144
+ class TestBaseManualFastAPI (TestBaseFastAPI ):
145
+
146
+ @classmethod
147
+ def setUpClass (cls ):
148
+ if cls is TestBaseManualFastAPI :
149
+ raise unittest .SkipTest (
150
+ f"{ cls .__name__ } is an abstract base class"
151
+ )
152
+
153
+ super (TestBaseManualFastAPI , cls ).setUpClass ()
136
154
137
155
def test_sub_app_fastapi_call (self ):
138
156
"""
@@ -177,7 +195,16 @@ def test_sub_app_fastapi_call(self):
177
195
)
178
196
179
197
180
- class BaseAutoFastAPI (BaseFastAPI ):
198
+ class TestBaseAutoFastAPI (TestBaseFastAPI ):
199
+
200
+ @classmethod
201
+ def setUpClass (cls ):
202
+ if cls is TestBaseAutoFastAPI :
203
+ raise unittest .SkipTest (
204
+ f"{ cls .__name__ } is an abstract base class"
205
+ )
206
+
207
+ super (TestBaseAutoFastAPI , cls ).setUpClass ()
181
208
182
209
def test_sub_app_fastapi_call (self ):
183
210
"""
@@ -232,7 +259,7 @@ def test_sub_app_fastapi_call(self):
232
259
)
233
260
234
261
235
- class TestFastAPIManualInstrumentation (BaseManualFastAPI , TestBase ):
262
+ class TestFastAPIManualInstrumentation (TestBaseManualFastAPI , TestBase ):
236
263
def test_instrument_app_with_instrument (self ):
237
264
if not isinstance (self , TestAutoInstrumentation ):
238
265
self ._instrumentor .instrument ()
@@ -472,7 +499,7 @@ async def _():
472
499
return app
473
500
474
501
475
- class TestFastAPIManualInstrumentationHooks (BaseManualFastAPI , TestBase ):
502
+ class TestFastAPIManualInstrumentationHooks (TestBaseManualFastAPI , TestBase ):
476
503
_server_request_hook = None
477
504
_client_request_hook = None
478
505
_client_response_hook = None
@@ -522,7 +549,7 @@ def client_response_hook(send_span, scope, message):
522
549
)
523
550
524
551
525
- class TestAutoInstrumentation (BaseAutoFastAPI , TestBase ):
552
+ class TestAutoInstrumentation (TestBaseAutoFastAPI , TestBase ):
526
553
"""Test the auto-instrumented variant
527
554
528
555
Extending the manual instrumentation as most test cases apply
@@ -636,7 +663,7 @@ def test_sub_app_fastapi_call(self):
636
663
)
637
664
638
665
639
- class TestAutoInstrumentationHooks (BaseAutoFastAPI , TestBase ):
666
+ class TestAutoInstrumentationHooks (TestBaseAutoFastAPI , TestBase ):
640
667
"""
641
668
Test the auto-instrumented variant for request and response hooks
642
669
0 commit comments