# Path: sigtools/support.py
# def read_sig(sig_str, ret=_util.UNSET, *,
#              use_modifiers_annotate=False,
#              use_modifiers_posoargs=sys.version_info < (3, 8),
#              use_modifiers_kwoargs=False,
#     ):
# def func_code(names, return_annotation, annotations, posoarg_n,
#               kwoarg_n, params, use_modifiers_annotate,
#               pre='', name='func',
#     ):
# def make_func(source, locals=None, name='func', future_features=()):
# def f(sig_str, ret=_util.UNSET, *, pre='', locals=None, name='func', future_features=(), **kwargs):
# def s(*args, **kwargs):
# def func_from_sig(sig):
# def make_up_callsigs(sig, extra=2):
# def bind_callsig(sig, args, kwargs):
# def sort_callsigs(sig, callsigs):
# def test_func_sig_coherent(func, check_return=True, check_invalid=True):
# DEBUG_STDLIB=False
# 
# Path: sigtools/_specifiers.py
# def forged_signature(obj, auto=True, args=(), kwargs={}):
# 
# Path: sigtools/tests/util.py
# def conv_first_posarg(sig):
# def func_to_name(func):
# def transform_exp_sources(d, subject=None):
# def transform_real_sources(d):
#     def assertSigsEqual(self, found, expected, *args, **kwargs):
#     def assertSourcesEqual(self, found, expected, func=None, depth_order=False):
#     def downgrade_sig(self, sig):
# class SignatureTests(unittest.TestCase):


import sys
from repeated_test import options
from sigtools import support, _specifiers
from sigtools.tests.util import Fixtures

def remove_spaces(s):
    return s.strip().replace(' ', '')


force_modifiers = {
        'use_modifiers_annotate': True,
        'use_modifiers_posoargs': True,
        'use_modifiers_kwoargs': True,
}


class RoundTripTests(Fixtures):
    def _test(self, sig_str, old_fmt=None):
        def assert_signature_matches_original(sig):
            self._assert_equal_ignoring_spaces(f'({sig_str})', str(sig), f'({old_fmt})')

        # Using inspect.signature
        sig = support.s(sig_str)
        assert_signature_matches_original(sig)

        # Roundtrip and use forged signature
        pf_sig = _specifiers.forged_signature(support.func_from_sig(sig))
        assert_signature_matches_original(pf_sig)

        # Using sigtools.modifiers and and inspect.signature
        m_sig = support.s(sig_str, **force_modifiers)
        assert_signature_matches_original(m_sig)

        # Roundtrip and use forged signature

# Path: sigtools/support.py
# def read_sig(sig_str, ret=_util.UNSET, *,
#              use_modifiers_annotate=False,
#              use_modifiers_posoargs=sys.version_info < (3, 8),
#              use_modifiers_kwoargs=False,
#     ):
# def func_code(names, return_annotation, annotations, posoarg_n,
#               kwoarg_n, params, use_modifiers_annotate,
#               pre='', name='func',
#     ):
# def make_func(source, locals=None, name='func', future_features=()):
# def f(sig_str, ret=_util.UNSET, *, pre='', locals=None, name='func', future_features=(), **kwargs):
# def s(*args, **kwargs):
# def func_from_sig(sig):
# def make_up_callsigs(sig, extra=2):
# def bind_callsig(sig, args, kwargs):
# def sort_callsigs(sig, callsigs):
# def test_func_sig_coherent(func, check_return=True, check_invalid=True):
# DEBUG_STDLIB=False
# 
# Path: sigtools/_specifiers.py
# def forged_signature(obj, auto=True, args=(), kwargs={}):
# 
# Path: sigtools/tests/util.py
# def conv_first_posarg(sig):
# def func_to_name(func):
# def transform_exp_sources(d, subject=None):
# def transform_real_sources(d):
#     def assertSigsEqual(self, found, expected, *args, **kwargs):
#     def assertSourcesEqual(self, found, expected, func=None, depth_order=False):
#     def downgrade_sig(self, sig):
# class SignatureTests(unittest.TestCase):


# Path: sigtools/tests/test_support.py
import sys
from repeated_test import options
from sigtools import support, _specifiers
from sigtools.tests.util import Fixtures


def remove_spaces(s):
    return s.strip().replace(' ', '')


force_modifiers = {
        'use_modifiers_annotate': True,
        'use_modifiers_posoargs': True,
        'use_modifiers_kwoargs': True,
}


class RoundTripTests(Fixtures):
    def _test(self, sig_str, old_fmt=None):
        def assert_signature_matches_original(sig):
            self._assert_equal_ignoring_spaces(f'({sig_str})', str(sig), f'({old_fmt})')

        # Using inspect.signature
        sig = support.s(sig_str)
        assert_signature_matches_original(sig)

        # Roundtrip and use forged signature
        pf_sig = _specifiers.forged_signature(support.func_from_sig(sig))
        assert_signature_matches_original(pf_sig)

        # Using sigtools.modifiers and and inspect.signature
        m_sig = support.s(sig_str, **force_modifiers)
        assert_signature_matches_original(m_sig)

        # Roundtrip and use forged signature

        pmf_sig = _specifiers.forged_signature(support.func_from_sig(m_sig))