Skip to content

Commit

Permalink
adjust test ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
epsy committed Oct 12, 2022
1 parent 5995207 commit a65eaed
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion sigtools/_signatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ def _is_co_flag_enabled(obj):
if not feature:
return False

if feature.mandatory and sys.version_info >= feature.mandatory:
mandatory_release = feature.getMandatoryRelease()
if mandatory_release and sys.version_info >= mandatory_release:
return True

try:
Expand Down
3 changes: 2 additions & 1 deletion sigtools/tests/test_sphinxext.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import unittest

from sigtools.tests import sphinxextfixt
from sigtools.tests import sphinxextfixt, util


app = object()
Expand Down Expand Up @@ -74,6 +74,7 @@ def test_inst_attr(self):
None, {}, None, None)
self.assertEqual((None, None), r)

@unittest.skipUnless(*util.python_has_optional_future_annotations)
def test_attrs_class(self):
r = self.sphinxext.process_signature(
app, '', 'sigtools.tests.sphinxextfixt.AttrsClass',
Expand Down
15 changes: 12 additions & 3 deletions sigtools/tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import warnings
from collections import defaultdict
from functools import partial
import __future__

import unittest
from repeated_test import tup, WithTestClass, with_options_matrix
Expand Down Expand Up @@ -175,12 +176,20 @@ def downgrade_param(self, param: funcsigs.Parameter):
Fixtures = WithTestClass(SignatureTests)


python_has_future_annotations = (3, 7, 0, "final") <= sys.version_info < (3, 11)
python_has_annotations = (3, 11) <= sys.version_info
python_has_future_annotations = hasattr(__future__, "annotations")
python_has_annotations = (
python_has_future_annotations
and __future__.annotations.getMandatoryRelease()
and __future__.annotations.getMandatoryRelease() <= sys.version_info
)
python_doesnt_have_future_annotations = (
(sys.version_info < (3, 7, 0, "final")),
not python_has_future_annotations,
"Python version does not have __future__.annotations"
)
python_has_optional_future_annotations = (
python_has_future_annotations and not python_has_annotations,
"Python version does not have optional __future__.annotations"
)


def signature_not_using_future_annotations(*args, **kwargs):
Expand Down

0 comments on commit a65eaed

Please sign in to comment.