<commit_before>"""
Test the Python 2.6 backport of OrderedDict.

Modified the Python 2.7 Lib/test/test_collections.py to test only
OrderedDict and slightly customized (and renamed) the modules
test_support.py and mapping_tests.py that provide support for those
tests.
"""

import unittest
import inspect
import pickle
import copy
from random import shuffle

import astropy.utils.tests.odict_mapping as mapping_tests

from astropy.utils.odict import OrderedDict


class TestOrderedDict(unittest.TestCase):

    def test_init(self):

        try:
            OrderedDict([('a', 1), ('b', 2)], None)                                 # too many args
            assert False
        except TypeError:
            pass
        else:
            assert False

        pairs = [('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e', 5)]
        self.assertEqual(sorted(OrderedDict(dict(pairs)).items()), pairs)           # dict input
        self.assertEqual(sorted(OrderedDict(**dict(pairs)).items()), pairs)         # kwds input
        self.assertEqual(list(OrderedDict(pairs).items()), pairs)                   # pairs input
        self.assertEqual(list(OrderedDict([('a', 1), ('b', 2), ('c', 9), ('d', 4)],
                                          c=3, e=5).items()), pairs)                # mixed input

        # make sure no positional args conflict with possible kwdargs
        self.assertEqual(inspect.getargspec(OrderedDict.__dict__['__init__']).args,
                         ['self'])

        # Make sure that direct calls to __init__ do not clear previous contents<commit_msg>skipping odict tests if builtin OrderedDict is in use<commit_after>"""
Test the Python 2.6 backport of OrderedDict.

Modified the Python 2.7 Lib/test/test_collections.py to test only
OrderedDict and slightly customized (and renamed) the modules
test_support.py and mapping_tests.py that provide support for those
tests.
"""

import unittest
import inspect
import pickle
import copy
import pytest
from random import shuffle

import astropy.utils.tests.odict_mapping as mapping_tests

from astropy.utils.odict import OrderedDict

#Skips all of these tests if the builtin ordered dict is available
pytestmark = pytest.mark.skipif("sys.version_info >= (2,7)")


class TestOrderedDict(unittest.TestCase):

    def test_init(self):

        try:
            OrderedDict([('a', 1), ('b', 2)], None)                                 # too many args
            assert False
        except TypeError:
            pass
        else:
            assert False

        pairs = [('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e', 5)]
        self.assertEqual(sorted(OrderedDict(dict(pairs)).items()), pairs)           # dict input
        self.assertEqual(sorted(OrderedDict(**dict(pairs)).items()), pairs)         # kwds input
        self.assertEqual(list(OrderedDict(pairs).items()), pairs)                   # pairs input
        self.assertEqual(list(OrderedDict([('a', 1), ('b', 2), ('c', 9), ('d', 4)],
                                          c=3, e=5).items()), pairs)                # mixed input

        # make sure no positional args conflict with possible kwdargs
        self.assertEqual(inspect.getargspec(OrderedDict.__dict__['__init__']).args,
                         ['self'])

        # Make sure that direct calls to __init__ do not clear previous contents
{'fraction_non_alphanumeric': 0.11567275996403956, 'fraction_numerical': 0.010788133053640995, 'mean_word_length': 2.441237113402062, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2742437', 'n_tokens_mistral': 956, 'n_tokens_neox': 904, 'n_words': 290}