Skip to content

Commit

Permalink
revert mock backends to numpy
Browse files Browse the repository at this point in the history
  • Loading branch information
rochisha0 committed Jul 18, 2024
1 parent ecc8441 commit ee3ae92
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions qutip/tests/core/test_numpy_backend.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
import numpy as np
from unittest.mock import patch, MagicMock

from ...settings import settings
Expand All @@ -17,18 +18,21 @@ def test_backend_property(self):

settings.core["numpy_backend"] = mock_jax
assert np_backend.backend is mock_jax
settings.core["numpy_backend"] = np

def test_getattr_numpy(self):
settings.core["numpy_backend"] = mock_np
np_backend = NumpyBackend()
mock_np.sum = MagicMock(return_value="numpy_sum")
assert np_backend.sum([1, 2, 3]) == "numpy_sum"
settings.core["numpy_backend"] = np

def test_getattr_jax(self):
settings.core["numpy_backend"] = mock_jax
np_backend = NumpyBackend()
mock_jax.sum = MagicMock(return_value="jax_sum")
assert np_backend.sum([1, 2, 3]) == "jax_sum"
settings.core["numpy_backend"] = np

@pytest.mark.parametrize("backend", [mock_np, mock_jax])
def test_backend_functionality(self, backend):
Expand All @@ -39,9 +43,5 @@ def test_backend_functionality(self, backend):
result = np_backend.sum([1, 2, 3])
assert result == "sum_result"
backend.sum.assert_called_with([1, 2, 3])
settings.core["numpy_backend"] = np


@pytest.fixture(scope='module')
def mock_settings():
with patch.dict(settings.core, {"numpy_backend": mock_np}):
yield settings

0 comments on commit ee3ae92

Please sign in to comment.