diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 1974cdc5..1071dfaf 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 64c8e3fa..804de793 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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: @@ -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 diff --git a/pytest.ini b/pytest.ini index 78fad96d..96127a14 100644 --- a/pytest.ini +++ b/pytest.ini @@ -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 + \ No newline at end of file diff --git a/python/snewpy/test/test_00_init.py b/python/snewpy/test/test_00_init.py index 6516e14b..c33276a6 100644 --- a/python/snewpy/test/test_00_init.py +++ b/python/snewpy/test/test_00_init.py @@ -1,6 +1,8 @@ import snewpy import unittest +import pytest +pytestmark=pytest.mark.base class TestInit(unittest.TestCase): def test_version_exists(self): diff --git a/python/snewpy/test/test_01_registry.py b/python/snewpy/test/test_01_registry.py index 68818417..13046586 100644 --- a/python/snewpy/test/test_01_registry.py +++ b/python/snewpy/test/test_01_registry.py @@ -15,6 +15,8 @@ import numpy as np +import pytest +pytestmark=[pytest.mark.models, pytest.mark.registry] class TestModels(unittest.TestCase): diff --git a/python/snewpy/test/test_02_models.py b/python/snewpy/test/test_02_models.py index 2b0afc5d..ecd83e8d 100644 --- a/python/snewpy/test/test_02_models.py +++ b/python/snewpy/test/test_02_models.py @@ -13,6 +13,8 @@ from snewpy import model_path import os +import pytest +pytestmark=pytest.mark.models class TestModels(unittest.TestCase): diff --git a/python/snewpy/test/test_03_neutrino.py b/python/snewpy/test/test_03_neutrino.py index ba6921c4..fbe8d839 100644 --- a/python/snewpy/test/test_03_neutrino.py +++ b/python/snewpy/test/test_03_neutrino.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- """Unit tests for the neutrino submodule. """ +import pytest +pytestmark=pytest.mark.base import unittest diff --git a/python/snewpy/test/test_04_xforms.py b/python/snewpy/test/test_04_xforms.py index 0ed0f99e..286cdee4 100644 --- a/python/snewpy/test/test_04_xforms.py +++ b/python/snewpy/test/test_04_xforms.py @@ -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): diff --git a/python/snewpy/test/test_flux_container.py b/python/snewpy/test/test_flux_container.py index 877925ae..0f7f65c2 100644 --- a/python/snewpy/test/test_flux_container.py +++ b/python/snewpy/test/test_flux_container.py @@ -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,