Skip to content

Commit

Permalink
Set seed for random number generators in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Feb 13, 2024
1 parent 37be024 commit bb75af2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,22 @@

from __future__ import annotations

import random

import numpy
import polars
import pytest
from sdssdb.peewee.sdss5db import catalogdb

from too.mock import create_mock_too_catalogue


SEED: int = 42
random.seed(SEED)
numpy.random.seed(SEED)
polars.set_random_seed(SEED)


DBNAME: str = "sdss5db_too_test"


Expand Down
3 changes: 3 additions & 0 deletions tests/test_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@
def test_mock_sample(too_mock: polars.DataFrame):
assert isinstance(too_mock, polars.DataFrame)
assert too_mock.height > 500000

# Check reproducibility of random numbers.
assert too_mock[12, "catalogid"] == 63050395369450584

0 comments on commit bb75af2

Please sign in to comment.