Skip to content

Commit

Permalink
Merge pull request #37 from FEniCS/test_fixes
Browse files Browse the repository at this point in the history
Remove pytest-cases dependency.
  • Loading branch information
dham authored Oct 21, 2019
2 parents ae587ff + 852d203 commit 825b23a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- checkout
- run:
name: Install dependencies # Install with sudo as tests not run as superuser in circleci/python
command: sudo pip install flake8 pytest pytest-cases pydocstyle numpy sympy coverage coveralls --upgrade
command: sudo pip install flake8 pytest pydocstyle numpy sympy coverage coveralls --upgrade
- run:
name: Install FIAT
command: pip install . --user
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ python:

before_install:
- pip install flake8
- pip install pytest pytest-cases
- pip install pytest

install:
- pip install .
Expand Down
2 changes: 1 addition & 1 deletion bitbucket-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pipelines:
- apt-get install -y
git python3-minimal python3-pip python3-setuptools python3-wheel
--no-install-recommends
- pip3 install flake8 pytest pytest-cases
- pip3 install flake8 pytest
- pip3 install .
- python3 -m flake8
- DATA_REPO_GIT="" python3 -m pytest -v test/
41 changes: 31 additions & 10 deletions test/unit/test_quadrature.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import numpy
import pytest
from pytest_cases import pytest_parametrize_plus, fixture_ref
import FIAT
from FIAT.reference_element import UFCInterval, UFCTriangle, UFCTetrahedron
from FIAT.reference_element import UFCQuadrilateral, UFCHexahedron, TensorProductCell
Expand Down Expand Up @@ -50,6 +49,22 @@ def hexahedron():
return UFCHexahedron()


# This unified fixture enables tests parametrised over different cells.
@pytest.fixture(params=["interval",
"triangle",
"quadrilateral",
"hexahedron"])
def cell(request):
if request.param == "interval":
return UFCInterval()
elif request.param == "triangle":
return UFCTriangle()
elif request.param == "quadrilateral":
return UFCTriangle()
elif request.param == "hexahedron":
return UFCTriangle()


@pytest.fixture(scope='module')
def extr_interval():
"""Extruded interval = interval x interval"""
Expand All @@ -68,6 +83,19 @@ def extr_quadrilateral():
return TensorProductCell(UFCQuadrilateral(), UFCInterval())


# This unified fixture enables tests parametrised over different extruded cells.
@pytest.fixture(params=["extr_interval",
"extr_triangle",
"extr_quadrilateral"])
def extr_cell(request):
if request.param == "extr_interval":
return TensorProductCell(UFCInterval(), UFCInterval())
elif request.param == "extr_triangle":
return TensorProductCell(UFCTriangle(), UFCInterval())
elif request.param == "extr_quadrilateral":
return TensorProductCell(UFCQuadrilateral(), UFCInterval())


@pytest.fixture(params=["canonical", "default"])
def scheme(request):
return request.param
Expand Down Expand Up @@ -135,21 +163,14 @@ def test_create_quadrature_extr_quadrilateral(extr_quadrilateral, basedeg, extrd
(2**(basedeg + 2) - 2) / ((basedeg + 1)*(basedeg + 2)) * 1/(extrdeg + 1))


@pytest_parametrize_plus("cell", [fixture_ref(interval),
fixture_ref(triangle),
fixture_ref(tetrahedron),
fixture_ref(quadrilateral)])
def test_invalid_quadrature_degree(cell, scheme):
with pytest.raises(ValueError):
FIAT.create_quadrature(cell, -1, scheme)


@pytest_parametrize_plus("cell", [fixture_ref(extr_interval),
fixture_ref(extr_triangle),
fixture_ref(extr_quadrilateral)])
def test_invalid_quadrature_degree_tensor_prod(cell):
def test_invalid_quadrature_degree_tensor_prod(extr_cell):
with pytest.raises(ValueError):
FIAT.create_quadrature(cell, (-1, -1))
FIAT.create_quadrature(extr_cell, (-1, -1))


def test_tensor_product_composition(interval, triangle, extr_triangle, scheme):
Expand Down

0 comments on commit 825b23a

Please sign in to comment.