Skip to content

Commit

Permalink
test(markers): add tests for custom markers
Browse files Browse the repository at this point in the history
I had a thought about a potential edge case with `None` being the only
listed "Exception" in a `raises` argument.  This fixes the edge case and
also adds some simple tests to make sure our custom markers correctly
handle when an imported backend exception is set to `None` due to a
missing import.
  • Loading branch information
gforsyth committed Jan 23, 2024
1 parent abec9f1 commit 421d6e7
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ibis/backends/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,14 @@ def _filter_none_from_raises(kwargs):
# Filter out any None values from kwargs['raises']
# to cover any missing backend error types as defined in ibis/backends/tests/errors.py
if (raises := kwargs.get("raises")) is not None:
kwargs["raises"] = tuple(filter(None, promote_tuple(raises)))
raises = tuple(filter(None, promote_tuple(raises)))
if raises:
kwargs["raises"] = raises
else:
# if filtering removes all of the values of raises pop the
# argument otherwise it gets passed as an empty tuple and this
# messes up xfail
kwargs.pop("raises")
return kwargs

# Ibis hasn't exposed existing functionality
Expand Down
67 changes: 67 additions & 0 deletions ibis/backends/tests/test_markers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from __future__ import annotations

import pytest

from ibis.backends.base import _get_backend_names

all_backends = list(_get_backend_names())


@pytest.mark.notimpl(all_backends)
def test_notimpl(con):
raise Exception


@pytest.mark.notimpl(all_backends, raises=None)
def test_notimpl_raises_none(con):
raise Exception


@pytest.mark.notimpl(all_backends, raises=(None, None))
def test_notimpl_raises_none_tuple(con):
raise Exception


@pytest.mark.notimpl(all_backends, raises=(Exception, None))
def test_notimpl_raises_tuple_exception_none(con):
raise Exception


@pytest.mark.notyet(all_backends)
def test_notyet(con):
raise Exception


@pytest.mark.notyet(all_backends, raises=None)
def test_notyet_raises_none(con):
raise Exception


@pytest.mark.notyet(all_backends, raises=(None, None))
def test_notyet_raises_none_tuple(con):
raise Exception


@pytest.mark.notyet(all_backends, raises=(Exception, None))
def test_notyet_raises_tuple_exception_none(con):
raise Exception


@pytest.mark.never(all_backends, reason="because I said so")
def test_never(con):
raise Exception


@pytest.mark.never(all_backends, raises=None, reason="because I said so")
def test_never_raises_none(con):
raise Exception


@pytest.mark.never(all_backends, raises=(None, None), reason="because I said so")
def test_never_raises_none_tuple(con):
raise Exception


@pytest.mark.never(all_backends, raises=(Exception, None), reason="because I said so")
def test_never_raises_tuple_exception_none(con):
raise Exception

0 comments on commit 421d6e7

Please sign in to comment.