bittensor
bittensor copied to clipboard
Improve tests
Is your feature request related to a problem? Please describe.
We have tests for many things, but they don't really test. Here's an example:
def test_set_weights(self):
chain_weights = [0]
self.subtensor.set_weights = MagicMock(return_value=True)
self.subtensor.do_set_weights = MagicMock(return_value=(True, None))
success = self.subtensor.set_weights(
wallet=self.wallet,
netuid=3,
uids=[1],
weights=chain_weights,
)
assert success is True
This test tests the subtensor.set_weights method, and it passes. However, if we modify the values:
def test_set_weights(self):
chain_weights = [0]
self.subtensor.set_weights = MagicMock(return_value=True)
self.subtensor.do_set_weights = MagicMock(return_value=(True, None))
success = self.subtensor.set_weights(
wallet="HELLO",
netuid=None,
uids=["not", "valid"],
weights={"this": "is a dict"},
)
assert success is True
It also passes. Even though it should absolutely not pass. This gives the appearance of us having a test for it, but it's not really a test. Many of the unit and integration tests in the repo are like this.
Describe the solution you'd like
Reduce the use of Mock. Only use it where it's actually applicable. Otherwise it just always passes.
Describe alternatives you've considered
No response
Additional context
No response