11
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
+ from __future__ import annotations
15
+
14
16
from dataclasses import dataclass
17
+ from textwrap import dedent
15
18
16
19
from uses_services .platform_rules import Platform
17
20
@@ -35,7 +38,9 @@ class ServiceSpecificMessages:
35
38
class ServiceMissingError (Exception ):
36
39
"""Error raised when a test uses a service but that service is missing."""
37
40
38
- def __init__ (self , service , platform : Platform , instructions = "" , msg = None ):
41
+ def __init__ (
42
+ self , service : str , platform : Platform , instructions : str = "" , msg = None
43
+ ):
39
44
if msg is None :
40
45
msg = f"The { service } service does not seem to be running or is not accessible!"
41
46
if instructions :
@@ -46,9 +51,9 @@ def __init__(self, service, platform: Platform, instructions="", msg=None):
46
51
self .instructions = instructions
47
52
48
53
@classmethod
49
- def generate_instructions (
54
+ def generate (
50
55
cls , platform : Platform , messages : ServiceSpecificMessages
51
- ):
56
+ ) -> ServiceMissingError :
52
57
service = messages .service
53
58
54
59
supported = False
@@ -154,4 +159,9 @@ def generate_instructions(
154
159
and start { service } . Good luck!
155
160
"""
156
161
)
157
- return instructions
162
+
163
+ return cls (
164
+ service = service ,
165
+ platform = platform ,
166
+ instructions = instructions ,
167
+ )
0 commit comments