1
1
from bittensor .core .subtensor import Subtensor
2
2
from bittensor .core .subtensor_api import SubtensorApi
3
+ import pytest
3
4
4
5
5
- def test_properties_methods_comparable ():
6
+ def test_properties_methods_comparable (other_class : "Subtensor" = None ):
6
7
"""Verifies that methods in SubtensorApi and its properties contains all Subtensors methods."""
7
8
# Preps
8
- subtensor = Subtensor (_mock = True )
9
+ subtensor = other_class ( _mock = True ) if other_class else Subtensor (_mock = True )
9
10
subtensor_api = SubtensorApi (_mock = True )
10
11
11
12
subtensor_methods = [m for m in dir (subtensor ) if not m .startswith ("_" )]
@@ -56,10 +57,12 @@ def test_properties_methods_comparable():
56
57
)
57
58
58
59
59
- def test__methods_comparable_with_passed_subtensor_fields ():
60
+ def test__methods_comparable_with_passed_subtensor_fields (
61
+ other_class : "Subtensor" = None ,
62
+ ):
60
63
"""Verifies that methods in SubtensorApi contains all Subtensors methods if `subtensor_fields=True` is passed."""
61
64
# Preps
62
- subtensor = Subtensor (_mock = True )
65
+ subtensor = other_class ( _mock = True ) if other_class else Subtensor (_mock = True )
63
66
subtensor_api = SubtensorApi (_mock = True , subtensor_fields = True )
64
67
65
68
subtensor_methods = [m for m in dir (subtensor ) if not m .startswith ("_" )]
@@ -75,3 +78,17 @@ def test__methods_comparable_with_passed_subtensor_fields():
75
78
assert method in subtensor_api_methods , (
76
79
f"`Subtensor.{ method } `is not present in class `SubtensorApi`."
77
80
)
81
+
82
+
83
+ def test_failed_if_subtensor_has_new_method ():
84
+ """Verifies that SubtensorApi fails if Subtensor has a new method."""
85
+ # Preps
86
+
87
+ class SubtensorWithNewMethod (Subtensor ):
88
+ def return_my_id (self ):
89
+ return id (self )
90
+
91
+ # Call and assert
92
+
93
+ with pytest .raises (AssertionError ):
94
+ test_properties_methods_comparable (other_class = SubtensorWithNewMethod )
0 commit comments