Skip to content

Commit

Permalink
fixup! Fix hynek#201 - Add support for contextvars
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusH committed Dec 24, 2019
1 parent e9d3942 commit d4291da
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
7 changes: 7 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

from __future__ import absolute_import, division, print_function

import sys

import pytest

from six.moves import cStringIO as StringIO
Expand All @@ -30,3 +32,8 @@ def __repr__(self):
return r"<A(\o/)>"

return {"a": A(), "b": [3, 4], "x": 7, "y": "test", "z": (1, 2)}


collect_ignore = []
if sys.version_info[:2] < (3, 7):
collect_ignore.extend(["tests/test_contextvars.py"])
31 changes: 8 additions & 23 deletions tests/test_contextvars.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,18 @@

import pytest


asyncio = pytest.importorskip("asyncio")
contextvars = pytest.importorskip("contextvars")


try:
from structlog.contextvars import (
bind_context_local,
clear_context_local,
merge_context_local,
unbind_context_local,
)
except ImportError:
skip_tests = True
else:
skip_tests = False

# All test coroutines will be treated as marked.
pytestmark = pytest.mark.asyncio
from structlog.contextvars import (
bind_context_local,
clear_context_local,
merge_context_local,
unbind_context_local,
)


supported_python = pytest.mark.skipif(
skip_tests, reason="Does not support asyncio or contextvars."
)
# All test coroutines will be treated as marked.
pytestmark = pytest.mark.asyncio


@supported_python
class TestNewContextvars(object):
async def test_bind(self, event_loop):
"""
Expand Down

0 comments on commit d4291da

Please sign in to comment.