File: conftest.py

package info (click to toggle)
python-sdjson 0.5.0-4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 560 kB
  • sloc: python: 1,566; makefile: 6; sh: 6
file content (25 lines) | stat: -rw-r--r-- 797 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# stdlib
from functools import singledispatch
from typing import Callable, Dict, Type

# 3rd party
import pytest

# this package
import sdjson
from sdjson import allow_unregister

pytest_plugins = ("coincidence", )


@pytest.fixture()
def monkeypatch_sdjson(monkeypatch):
	_registry = allow_unregister(singledispatch(lambda x: None))  # type: ignore[arg-type]
	_protocol_registry: Dict[Type, Callable] = {}
	registry = _registry.registry
	monkeypatch.setattr(sdjson.encoders, "_registry", _registry)
	monkeypatch.setattr(sdjson.encoders, "_protocol_registry", _protocol_registry)
	monkeypatch.setattr(sdjson.encoders, "registry", registry)
	assert sdjson.encoders._registry is _registry
	assert sdjson.encoders._protocol_registry is _protocol_registry
	assert sdjson.encoders.registry is registry