Skip to content

Commit

Permalink
gh-257: use pytest-mock instead of unittest.mock (#258)
Browse files Browse the repository at this point in the history
Replaces `unittest.mock.Mock` with pytest's mocking plugin -
`pytest-mock` ( a new `tests` dependency now).

Closes: #257

Co-authored-by: Patrick J. Roddy <[email protected]>
  • Loading branch information
Saransh-cpp and paddyroddy authored Sep 26, 2024
1 parent 35ebdea commit 574f577
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ test = [
"pytest",
"pytest-cov",
"pytest-doctestplus",
"pytest-mock",
"scipy",
]

Expand Down
6 changes: 2 additions & 4 deletions tests/test_galaxies.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import pytest


def test_redshifts():
from unittest.mock import Mock

def test_redshifts(mocker):
import numpy as np

from glass.galaxies import redshifts

# create a mock radial window function
w = Mock()
w = mocker.Mock()
w.za = np.linspace(0.0, 1.0, 20)
w.wa = np.exp(-0.5 * (w.za - 0.5) ** 2 / 0.1**2)

Expand Down

0 comments on commit 574f577

Please sign in to comment.