<commit_before># Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import print_function

import numpy as np

from astropy.tests.helper import remote_data
from astropy.table import Table
import astropy.units as u

from ... import nist


@remote_data
class TestNist:

    def test_query_async(self):
        response = nist.core.Nist.query_async(4000 * u.nm, 7000 * u.nm)
        assert response is not None

    def test_query(self):
        result = nist.core.Nist.query(4000 * u.nm, 7000 * u.nm)
        assert isinstance(result, Table)

        # check that no javascript was left in the table
        # (regression test for 1355)
        assert np.all(result['TP'] == 'T8637')<commit_msg>test_nist_remote: Added test of parsing raw HTML codes.<commit_after># Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import print_function

import numpy as np

from astropy.tests.helper import remote_data
from astropy.table import Table
import astropy.units as u

from ... import nist


@remote_data
class TestNist:

    def test_query_async(self):
        response = nist.core.Nist.query_async(4000 * u.nm, 7000 * u.nm)
        assert response is not None

    def test_query(self):
        result = nist.core.Nist.query(4000 * u.nm, 7000 * u.nm)
        assert isinstance(result, Table)

        # check that no javascript was left in the table
        # (regression test for 1355)
        assert np.all(result['TP'] == 'T8637')

    def test_unescape_html(self):
        response = nist.core.Nist.query_async(4333 * u.AA, 4334 * u.AA, "V I")
        assert '&dagger;' in response.text
        # check that Unicode characters have been properly unescaped from their
        # raw HTML code equivalents during parsing
        response = nist.core.Nist._parse_result(response)
        assert any('†' in s for s in response['Ei           Ek'])
{'fraction_non_alphanumeric': 0.08711721224920803, 'fraction_numerical': 0.030623020063357972, 'mean_word_length': 2.9397089397089395, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '7647177', 'n_tokens_mistral': 633, 'n_tokens_neox': 572, 'n_words': 194}