<commit_before>#------------------------------------------------------------------------------
#
#  Copyright (c) 2007, Enthought, Inc.
#  All rights reserved.
#
#  This software is provided without warranty under the terms of the BSD
#  license included in /LICENSE.txt and may be redistributed only
#  under the conditions described in the aforementioned license.  The license
#  is also available online at http://www.enthought.com/licenses/BSD.txt
#
#  Thanks for using Enthought open source!
#
#------------------------------------------------------------------------------
""" Test cases for dictionary (Dict) traits. """


from __future__ import absolute_import

from traits.testing.unittest_tools import unittest

from ..api import on_trait_change, Dict, Event, HasTraits, Str


# fixme: We'd like to use a callable instance for the listener so that we
# can maintain state, but traits barfs trying to determine the signature 8^()
def create_listener():
    """ Create a listener for testing trait notifications. """

    def listener(obj, trait_name, old, new):

        listener.obj        = obj
        listener.trait_name = trait_name
        listener.new        = new
        listener.old        = old
        listener.called     += 1

        return
<commit_msg>update imports to not use the `api` module<commit_after>#------------------------------------------------------------------------------
#
#  Copyright (c) 2007, Enthought, Inc.
#  All rights reserved.
#
#  This software is provided without warranty under the terms of the BSD
#  license included in /LICENSE.txt and may be redistributed only
#  under the conditions described in the aforementioned license.  The license
#  is also available online at http://www.enthought.com/licenses/BSD.txt
#
#  Thanks for using Enthought open source!
#
#------------------------------------------------------------------------------
""" Test cases for dictionary (Dict) traits. """


from __future__ import absolute_import

from traits.testing.unittest_tools import unittest

from ..trait_types import Dict, Event, Str, TraitDictObject
from ..has_traits import HasTraits, on_trait_change
from ..trait_errors import TraitError


# fixme: We'd like to use a callable instance for the listener so that we
# can maintain state, but traits barfs trying to determine the signature 8^()
def create_listener():
    """ Create a listener for testing trait notifications. """

    def listener(obj, trait_name, old, new):

        listener.obj        = obj
        listener.trait_name = trait_name
        listener.new        = new
        listener.old        = old
        listener.called     += 1

        return

{'fraction_non_alphanumeric': 0.18365817091454273, 'fraction_numerical': 0.004497751124437781, 'mean_word_length': 2.067816091954023, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7296157', 'n_tokens_mistral': 668, 'n_tokens_neox': 634, 'n_words': 265}