Skip to content

Commit

Permalink
Updating @slow marker for pytest.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermes committed Aug 7, 2019
1 parent 26acc38 commit 46f8b57
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
23 changes: 23 additions & 0 deletions tests/conftest.py
Expand Up @@ -22,8 +22,14 @@
import sys
import unittest

import pytest
import six

try:
from bezier import _HAS_SPEEDUP as HAS_SPEEDUP
except ImportError: # pragma: NO COVER
HAS_SPEEDUP = False

if six.PY2:
import mock # pylint: disable=import-error

Expand All @@ -38,3 +44,20 @@ def pytest_addoption(parser):
action="store_true",
help="Ignore slow tests.",
)


def pytest_configure(config):
config.addinivalue_line("markers", "slow: mark test as slow to run")


def pytest_collection_modifyitems(config, items):
if not config.getoption("--ignore-slow"):
return

if HAS_SPEEDUP:
return

skip_slow = pytest.mark.skip(reason="--ignore-slow ignores the slow tests")
for item in items:
if "slow" in item.keywords:
item.add_marker(skip_slow)
20 changes: 5 additions & 15 deletions tests/unit/test__surface_helpers.py
Expand Up @@ -15,21 +15,11 @@
import numpy as np
import pytest

try:
from bezier import _HAS_SPEEDUP as HAS_SPEEDUP
except ImportError: # pragma: NO COVER
HAS_SPEEDUP = False
from tests.unit import utils

UNIT_TRIANGLE = np.asfortranarray([[0.0, 1.0, 0.0], [0.0, 0.0, 1.0]])
FLOAT64 = np.float64 # pylint: disable=no-member
SPACING = np.spacing # pylint: disable=no-member
# pylint: disable=invalid-name,no-member
slow = pytest.mark.skipif(
pytest.config.getoption("--ignore-slow") and not HAS_SPEEDUP,
reason="--ignore-slow ignores the slow tests",
)
# pylint: enable=invalid-name,no-member


class Test_polynomial_sign(unittest.TestCase):
Expand Down Expand Up @@ -503,7 +493,7 @@ def test_linear(self):
UNIT_TRIANGLE, 1, expected_a, expected_b, expected_c, expected_d
)

@slow
@pytest.mark.slow
def test_line_check_evaluate(self):
# Use a fixed seed so the test is deterministic and round
# the nodes to 8 bits of precision to avoid round-off.
Expand Down Expand Up @@ -540,7 +530,7 @@ def test_quadratic(self):
)
self._helper(nodes, 2, expected_a, expected_b, expected_c, expected_d)

@slow
@pytest.mark.slow
def test_quadratic_check_evaluate(self):
# Use a fixed seed so the test is deterministic and round
# the nodes to 8 bits of precision to avoid round-off.
Expand Down Expand Up @@ -668,21 +658,21 @@ def test_cubic(self):
)
self._helper(nodes, 3, expected_a, expected_b, expected_c, expected_d)

@slow
@pytest.mark.slow
def test_cubic_check_evaluate(self):
# Use a fixed seed so the test is deterministic and round
# the nodes to 8 bits of precision to avoid round-off.
nodes = utils.get_random_nodes(shape=(2, 10), seed=346323, num_bits=8)
self._points_check(nodes, 3)

@slow
@pytest.mark.slow
def test_quartic_check_evaluate(self):
# Use a fixed seed so the test is deterministic and round
# the nodes to 8 bits of precision to avoid round-off.
nodes = utils.get_random_nodes(shape=(2, 15), seed=741002, num_bits=8)
self._points_check(nodes, 4)

@slow
@pytest.mark.slow
def test_on_the_fly(self):
# Test for a degree where the subdivision is done on the fly
# rather than via a stored matrix.
Expand Down

0 comments on commit 46f8b57

Please sign in to comment.