File: test_multiple_files.py

package info (click to toggle)
python-sdjson 0.5.0-4
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 560 kB
  • sloc: python: 1,566; makefile: 6; sh: 6
file content (30 lines) | stat: -rw-r--r-- 655 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
26
27
28
29
30
"""
Test registering custom encoders in multiple files
"""

# stdlib
from decimal import Decimal
from fractions import Fraction

# 3rd party
import pytest

# this package
import sdjson


@pytest.mark.usefixtures("monkeypatch_sdjson")
def test_multiple_files() -> None:

	# this package
	from .glossia import talon, thorn  # noqa: F401

	# Test that we get the expected output when encoding a Decimal
	assert sdjson.dumps(Decimal(1)) == '"1"'

	# Test that we get the expected output when encoding a Fraction
	assert sdjson.dumps(Fraction(2, 3)) == '"2/3"'

	# Cleanup
	sdjson.encoders.unregister(Decimal, True)
	sdjson.encoders.unregister(Fraction, True)