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

Sheshuk/use test labels #292

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,4 @@ jobs:
run: |
pip install ".[dev]"
- name: Run Integration Tests
run: |
python -m unittest python/snewpy/test/simplerate_integrationtest.py
pytest -m 'snowglobes'
run: python -m unittest python/snewpy/test/simplerate_integrationtest.py
20 changes: 17 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
branches: [ main ]
pull_request:
branches: [ main ]
types: [opened, synchronize, reopened, ready_for_review, labeled]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand Down Expand Up @@ -39,6 +40,19 @@ jobs:
pip install ".[dev]"

# Run the unit tests
- name: Test with pytest
run: |
pytest -m 'not snowglobes'
- name: Testing base functionality
run: pytest -m 'base'

- name: Testing ModelRegistry
if: contains(github.event.pull_request.labels.*.name, 'ModelRegistry')
run: pytest -m 'registry'
- name: Testing Models
if: contains(github.event.pull_request.labels.*.name, 'SupernovaModel')
run: pytest -m 'models'
- name: Testing SNOwGLoBES
if: contains(github.event.pull_request.labels.*.name, 'SNOwGLoBES')
run: pytest -m 'snowglobes'
#This will trigger only when user adds a "test:All" label
- name: Run all tests
if: ${{ github.event.label.name == 'test:All' }}
run: pytest
6 changes: 4 additions & 2 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[pytest]
markers=
base: testing basic functionality (neutrino, flavor transformations etc)
snowglobes: tests that require SNOwGLoBES installed
crosscheck: integration tests for comparison with reference output
timing: benchmark testing of the function execution time


models: testing initialization of neutrino models
registry: testing ModelRegistry - downloading data files from remote location

2 changes: 2 additions & 0 deletions python/snewpy/test/test_00_init.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import snewpy
import unittest

import pytest
pytestmark=pytest.mark.base

class TestInit(unittest.TestCase):
def test_version_exists(self):
Expand Down
2 changes: 2 additions & 0 deletions python/snewpy/test/test_01_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

import numpy as np

import pytest
pytestmark=[pytest.mark.models, pytest.mark.registry]

class TestModels(unittest.TestCase):

Expand Down
2 changes: 2 additions & 0 deletions python/snewpy/test/test_02_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from snewpy import model_path
import os

import pytest
pytestmark=pytest.mark.models

class TestModels(unittest.TestCase):

Expand Down
2 changes: 2 additions & 0 deletions python/snewpy/test/test_03_neutrino.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
"""Unit tests for the neutrino submodule.
"""
import pytest
pytestmark=pytest.mark.base

import unittest

Expand Down
3 changes: 3 additions & 0 deletions python/snewpy/test/test_04_xforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
import numpy as np
from numpy import sin, cos, exp, abs

import pytest
pytestmark=pytest.mark.base

class TestFlavorTransformations(unittest.TestCase):

def setUp(self):
Expand Down
1 change: 1 addition & 0 deletions python/snewpy/test/test_flux_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import numpy as np
import astropy.units as u
import pytest
pytestmark=pytest.mark.base
#define strategies to generate float values
def float_values(shape=array_shapes(max_dims=1),**kwargs):
return arrays(float, shape=shape,
Expand Down