<commit_before># -*- coding: utf-8 -*-
"""
Created on Fri Sep 20 13:58:00 2013

@author: yves
"""

from __future__ import division,print_function,unicode_literals,absolute_import

from traits.testing.unittest_tools import unittest

from ..api import HasStrictTraits, Str, Any

class TestSpecialEvent( unittest.TestCase ):
    """ Test demonstrating special change events using the 'event' metadata.
    """
    def setUp(self):
        self.change_events = []
        self.foo = Foo( test=self )
        return

    def test_events(self):
        self.foo.val = 'CHANGE'
        
        values = ['CHANGE']
        self.failUnlessEqual( self.change_events, values)
        return

    def test_instance_events(self):
        foo = self.foo
        foo.add_trait('val2',Str(event='the_trait'))
        foo.val2 = 'CHANGE2'
        
        values = ['CHANGE2']
        self.failUnlessEqual( self.change_events, values)
        return


class Foo(HasStrictTraits):
    val = Str(event='the_trait')
    test = Any(None)
    
    def _the_trait_changed(self,new):
        if self.test is not None:
            self.test.change_events.append(new)
    
    <commit_msg>Fix style issues.<commit_after>from traits.testing.unittest_tools import unittest

from traits.api import Any, HasStrictTraits, Str


class TestSpecialEvent( unittest.TestCase ):
    """ Test demonstrating special change events using the 'event' metadata.
    """

    def setUp(self):
        self.change_events = []
        self.foo = Foo( test=self )

    def test_events(self):
        self.foo.val = 'CHANGE'

        values = ['CHANGE']
        self.failUnlessEqual( self.change_events, values)

    def test_instance_events(self):
        foo = self.foo
        foo.add_trait('val2',Str(event='the_trait'))
        foo.val2 = 'CHANGE2'

        values = ['CHANGE2']
        self.failUnlessEqual( self.change_events, values)


class Foo(HasStrictTraits):
    val = Str(event='the_trait')
    test = Any(None)
    
    def _the_trait_changed(self,new):
        if self.test is not None:
            self.test.change_events.append(new)
{'fraction_non_alphanumeric': 0.11031859248692344, 'fraction_numerical': 0.009985734664764621, 'mean_word_length': 2.6912280701754385, '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': '242584', 'n_tokens_mistral': 667, 'n_tokens_neox': 650, 'n_words': 147}