Skip to content

Commit

Permalink
Make tests pass for python 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmojaki committed Sep 30, 2023
1 parent c637c2a commit c86ff98
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ install_requires =

setup_requires = setuptools>=44; setuptools_scm[toml]>=3.4.3
include_package_data = True
tests_require = pytest; typeguard; pygments>=2.16.0; littleutils
tests_require = pytest; typeguard; pygments; littleutils

[options.extras_require]
tests = pytest; typeguard; pygments>=2.16.0; littleutils; cython
tests = pytest; typeguard; pygments; littleutils; cython

[coverage:run]
relative_files = True
Expand Down
5 changes: 4 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import os

import pyximport
from typeguard import install_import_hook
try:
from typeguard import install_import_hook
except ImportError:
from typeguard.importhook import install_import_hook

pyximport.install(language_level=3)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ def test_example():
)


compare_to_file_json(result, "serialize")
compare_to_file_json(result, "serialize", pygmented=True)
14 changes: 13 additions & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import os

import pygments
from littleutils import string_to_file, file_to_string, json_to_file, file_to_json


def parse_version(version: str):
return tuple(int(x) for x in version.split("."))


old_pygments = parse_version(pygments.__version__) < (2, 16, 1)


def compare_to_file(text, name):
if old_pygments and "pygment" in name:
return
filename = os.path.join(
os.path.dirname(__file__),
'golden_files',
Expand All @@ -16,7 +26,9 @@ def compare_to_file(text, name):
assert text == expected_output


def compare_to_file_json(data, name):
def compare_to_file_json(data, name, *, pygmented):
if old_pygments and pygmented:
return
filename = os.path.join(
os.path.dirname(__file__),
'golden_files',
Expand Down

0 comments on commit c86ff98

Please sign in to comment.