# Path: clearly/utils/safe_compiler.py
# NON_PRINTABLE_PATTERN = re.compile('[\x00-\x1f]')
# def safe_compile_text(txt: str, raises: bool = False) -> Any:
#     def _convert(node):
# def _encode_to_hex(match: Match) -> str:


import pytest
from clearly.utils.safe_compiler import CallDescriptor, safe_compile_text
                     'ignore': ['False']})),

    ('Decimal("3.50"), [f1(True, ok=0), f2(ignore=set(("x", "y")))]',
     (CallDescriptor('Decimal', ('3.50',), None),
      [CallDescriptor('f1', (True,), {'ok': 0}),
       CallDescriptor('f2', None, {'ignore': {'x', 'y'}})])),
])
def test_safe_compile_generic(text, obj):
    assert safe_compile_text(text) == obj


INVALID = [
    'a a',
    '$',
    'a=1',  # it's invalid in 'eval' ast mode.
    'import time',  # it's invalid in 'eval' ast mode.
    'if import',
    '1 if True: else 1',
    'if True: pass; else 1',  # it's invalid in 'eval' ast mode.
]


@pytest.mark.parametrize('text', INVALID)
def test_safe_compile_invalid_python(text):
    assert safe_compile_text(text) == text


@pytest.mark.parametrize('text', INVALID)
def test_safe_compile_invalid_python_with_raises(text):
    with pytest.raises(SyntaxError):

# Path: clearly/utils/safe_compiler.py
# NON_PRINTABLE_PATTERN = re.compile('[\x00-\x1f]')
# def safe_compile_text(txt: str, raises: bool = False) -> Any:
#     def _convert(node):
# def _encode_to_hex(match: Match) -> str:


# Path: tests/unit/utils/test_safe_compiler.py
import pytest
from clearly.utils.safe_compiler import CallDescriptor, safe_compile_text

                     'ignore': ['False']})),

    ('Decimal("3.50"), [f1(True, ok=0), f2(ignore=set(("x", "y")))]',
     (CallDescriptor('Decimal', ('3.50',), None),
      [CallDescriptor('f1', (True,), {'ok': 0}),
       CallDescriptor('f2', None, {'ignore': {'x', 'y'}})])),
])
def test_safe_compile_generic(text, obj):
    assert safe_compile_text(text) == obj


INVALID = [
    'a a',
    '$',
    'a=1',  # it's invalid in 'eval' ast mode.
    'import time',  # it's invalid in 'eval' ast mode.
    'if import',
    '1 if True: else 1',
    'if True: pass; else 1',  # it's invalid in 'eval' ast mode.
]


@pytest.mark.parametrize('text', INVALID)
def test_safe_compile_invalid_python(text):
    assert safe_compile_text(text) == text


@pytest.mark.parametrize('text', INVALID)
def test_safe_compile_invalid_python_with_raises(text):
    with pytest.raises(SyntaxError):

        safe_compile_text(text, raises=True)