Skip to content

Commit 23a862f

Browse files
author
Roman
committed
one more compatability test
1 parent 62ebe3a commit 23a862f

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

tests/unit_tests/test_subtensor_api.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
from bittensor.core.subtensor import Subtensor
22
from bittensor.core.subtensor_api import SubtensorApi
3+
import pytest
34

45

5-
def test_properties_methods_comparable():
6+
def test_properties_methods_comparable(other_class: "Subtensor" = None):
67
"""Verifies that methods in SubtensorApi and its properties contains all Subtensors methods."""
78
# Preps
8-
subtensor = Subtensor(_mock=True)
9+
subtensor = other_class(_mock=True) if other_class else Subtensor(_mock=True)
910
subtensor_api = SubtensorApi(_mock=True)
1011

1112
subtensor_methods = [m for m in dir(subtensor) if not m.startswith("_")]
@@ -56,10 +57,12 @@ def test_properties_methods_comparable():
5657
)
5758

5859

59-
def test__methods_comparable_with_passed_subtensor_fields():
60+
def test__methods_comparable_with_passed_subtensor_fields(
61+
other_class: "Subtensor" = None,
62+
):
6063
"""Verifies that methods in SubtensorApi contains all Subtensors methods if `subtensor_fields=True` is passed."""
6164
# Preps
62-
subtensor = Subtensor(_mock=True)
65+
subtensor = other_class(_mock=True) if other_class else Subtensor(_mock=True)
6366
subtensor_api = SubtensorApi(_mock=True, subtensor_fields=True)
6467

6568
subtensor_methods = [m for m in dir(subtensor) if not m.startswith("_")]
@@ -75,3 +78,17 @@ def test__methods_comparable_with_passed_subtensor_fields():
7578
assert method in subtensor_api_methods, (
7679
f"`Subtensor.{method}`is not present in class `SubtensorApi`."
7780
)
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

Comments
 (0)