Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tests #2354

Open
thewhaleking opened this issue Oct 16, 2024 · 0 comments
Open

Improve tests #2354

thewhaleking opened this issue Oct 16, 2024 · 0 comments
Labels
enhancement New feature or request feature new feature added

Comments

@thewhaleking
Copy link
Contributor

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

@thewhaleking thewhaleking added feature new feature added enhancement New feature or request labels Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature new feature added
Projects
None yet
Development

No branches or pull requests

1 participant