<commit_before># Licensed under a 3-clause BSD style license - see LICENSE.rst
from ....tests.helper import raises

# LOCAL
from .. import converters
from .. import exceptions
from .. import tree


def test_reraise():
    def fail():
        raise RuntimeError("This failed")

    try:
        try:
            fail()
        except RuntimeError as e:
            exceptions.vo_reraise(e, additional="From here")
    except RuntimeError as e:
        assert "From here" in str(e)
    else:
        assert False


def test_parse_vowarning(recwarn):
    config = {'pedantic': True,
              'filename': 'foo.xml'}
    pos = (42, 64)
    field = tree.Field(
        None, name='c', datatype='char',
        config=config, pos=pos)
    c = converters.get_converter(field, config=config, pos=pos)
    w = recwarn.pop(exceptions.W47)

    parts = exceptions.parse_vowarning(str(w.message))

    match = {
        'number'       : 47,
        'is_exception' : False,
        'nchar'        : 64,
        'warning'      : 'W47',
        'is_something' : True,
        'message'      : 'Missing arraysize indicates length 1',
        'doc_url'      : 'vo/api_exceptions.html#w47',
        'nline'        : 42,
        'is_warning'   : True
        }
    assert parts == match<commit_msg>Fix test<commit_after># Licensed under a 3-clause BSD style license - see LICENSE.rst
from ....tests.helper import raises

# LOCAL
from .. import converters
from .. import exceptions
from .. import tree


def test_reraise():
    def fail():
        raise RuntimeError("This failed")

    try:
        try:
            fail()
        except RuntimeError as e:
            exceptions.vo_reraise(e, additional="From here")
    except RuntimeError as e:
        assert "From here" in str(e)
    else:
        assert False


def test_parse_vowarning(recwarn):
    config = {'pedantic': True,
              'filename': 'foo.xml'}
    pos = (42, 64)
    field = tree.Field(
        None, name='c', datatype='char',
        config=config, pos=pos)
    c = converters.get_converter(field, config=config, pos=pos)
    w = recwarn.pop(exceptions.W47)

    parts = exceptions.parse_vowarning(str(w.message))

    match = {
        'number'       : 47,
        'is_exception' : False,
        'nchar'        : 64,
        'warning'      : 'W47',
        'is_something' : True,
        'message'      : 'Missing arraysize indicates length 1',
        'doc_url'      : 'io/votable/api_exceptions.html#w47',
        'nline'        : 42,
        'is_warning'   : True
        }
    assert parts == match
{'fraction_non_alphanumeric': 0.11872323861424679, 'fraction_numerical': 0.014013234721681589, 'mean_word_length': 2.063170441001192, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7475447', 'n_tokens_mistral': 826, 'n_tokens_neox': 785, 'n_words': 208}