<s> from __future__ import absolute_import <EOL> from traits . testing . unittest_tools import unittest <EOL> from . . api import HasTraits , Instance , Str <EOL> class Shared ( HasTraits ) : <EOL> s = Str ( '<STR_LIT>' ) <EOL> class Foo ( HasTraits ) : <EOL> s = Str ( '<STR_LIT>' ) <EOL> shared = Instance ( Shared ) <EOL> class Bar ( HasTraits ) : <EOL> s = Str ( '<STR_LIT>' ) <EOL> foo = Instance ( Foo ) <EOL> shared = Instance ( Shared ) <EOL> class Baz ( HasTraits ) : <EOL> s = Str ( '<STR_LIT>' ) <EOL> bar = Instance ( Bar ) <EOL> shared = Instance ( Shared ) <EOL> class CopyTraitsBase ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> __test__ = False <EOL> def setUp ( self ) : <EOL> super ( CopyTraitsBase , self ) . setUp ( ) <EOL> self . shared = Shared ( s = '<STR_LIT>' ) <EOL> self . foo = Foo ( shared = self . shared , s = '<STR_LIT:foo>' ) <EOL> self . bar = Bar ( shared = self . shared , foo = self . foo , s = '<STR_LIT:bar>' ) <EOL> self . baz = Baz ( shared = self . shared , bar = self . bar , s = '<STR_LIT>' ) <EOL> self . shared2 = Shared ( s = '<STR_LIT>' ) <EOL> self . foo2 = Foo ( shared = self . shared2 , s = '<STR_LIT>' ) <EOL> self . bar2 = Bar ( shared = self . shared2 , foo = self . foo2 , s = '<STR_LIT>' ) <EOL> self . baz2 = Baz ( shared = self . shared2 , bar = self . bar2 , s = '<STR_LIT>' ) <EOL> return <EOL> def set_shared_copy ( self , value ) : <EOL> """<STR_LIT>""" <EOL> self . foo . base_trait ( '<STR_LIT>' ) . copy = value <EOL> self . bar . base_trait ( '<STR_LIT>' ) . copy = value <EOL> self . baz . base_trait ( '<STR_LIT>' ) . copy = value <EOL> class TestCopyTraitsSetup ( CopyTraitsBase ) : <EOL> __test__ = True <EOL> def setUp ( self ) : <EOL> super ( TestCopyTraitsSetup , self ) . setUp ( ) <EOL> def test_setup ( self ) : <EOL> self . assertIs ( self . foo , self . bar . foo ) <EOL> self . assertIs ( self . bar , self . baz . bar ) <EOL> self . assertIs ( self . foo . shared , self . shared ) <EOL> self . assertIs ( self . bar . shared , self . shared ) <EOL> self . assertIs ( self . baz . shared , self . shared ) <EOL> self . assertIs ( self . foo2 , self . bar2 . foo ) <EOL> self . assertIs ( self . bar2 , self . baz2 . bar ) <EOL> self . assertIs ( self . foo2 . shared , self . shared2 ) <EOL> self . assertIs ( self . bar2 . shared , self . shared2 ) <EOL> self . assertIs ( self . baz2 . shared , self . shared2 ) <EOL> class CopyTraits ( object ) : <EOL> def test_baz2_s ( self ) : <EOL> self . assertEqual ( self . baz2 . s , '<STR_LIT>' ) <EOL> self . assertEqual ( self . baz2 . s , self . baz . s ) <EOL> def test_baz2_bar_s ( self ) : <EOL> self . assertEqual ( self . baz2 . bar . s , '<STR_LIT:bar>' ) <EOL> self . assertEqual ( self . baz2 . bar . s , self . baz . bar . s ) <EOL> def test_baz2_bar_foo_s ( self ) : <EOL> self . assertEqual ( self . baz2 . bar . foo . s , '<STR_LIT:foo>' ) <EOL> self . assertEqual ( self . baz2 . bar . foo . s , self . baz . bar . foo . s ) <EOL> def test_baz2_shared_s ( self ) : <EOL> self . assertEqual ( self . baz2 . shared . s , '<STR_LIT>' ) <EOL> self . assertEqual ( self . baz2 . bar . shared . s , '<STR_LIT>' ) <EOL> self . assertEqual ( self . baz2 . bar . foo . shared . s , '<STR_LIT>' ) <EOL> def test_baz2_bar ( self ) : <EOL> self . assertIsNot ( self . baz2 . bar , None ) <EOL> self . assertIsNot ( self . baz2 . bar , self . bar2 ) <EOL> self . assertIsNot ( self . baz2 . bar , self . baz . bar ) <EOL> def test_baz2_bar_foo ( self ) : <EOL> self . assertIsNot ( self . baz2 . bar . foo , None ) <EOL> self . assertIsNot ( self . baz2 . bar . foo , self . foo2 ) <EOL> self . assertIsNot ( self . baz2 . bar . foo , self . baz . bar . foo ) <EOL> class CopyTraitsSharedCopyNone ( object ) : <EOL> def test_baz2_shared ( self ) : <EOL> self . assertIsNot ( self . baz2 . shared , None ) <EOL> self . assertIsNot ( self . baz2 . shared , self . shared2 ) <EOL> self . assertIsNot ( self . baz2 . shared , self . shared ) <EOL> def test_baz2_bar_shared ( self ) : <EOL> self . assertIsNot ( self . baz2 . bar . shared , None ) <EOL> self . assertIsNot ( self . baz2 . bar . shared , self . shared2 ) <EOL> self . assertIsNot ( self . baz2 . bar . shared , self . shared ) <EOL> self . assertIsNot ( self . baz2 . bar . shared , self . baz2 . shared ) <EOL> def test_baz2_bar_foo_shared ( self ) : <EOL> self . assertIsNot ( self . baz2 . bar . foo . shared , None ) <EOL> self . assertIsNot ( self . baz2 . bar . foo . shared , self . shared2 ) <EOL> self . assertIsNot ( self . baz2 . bar . foo . shared , self . shared ) <EOL> self . assertIsNot ( self . baz2 . bar . foo . shared , self . baz2 . shared ) <EOL> def test_baz2_bar_and_foo_shared ( self ) : <EOL> self . assertIs ( self . baz2 . bar . shared , self . baz2 . bar . foo . shared ) <EOL> self . assertIsNot ( self . baz2 . shared , self . baz2 . bar . foo . shared ) <EOL> class TestCopyTraitsSharedCopyNone ( CopyTraits , <EOL> CopyTraitsSharedCopyNone ) : <EOL> __test__ = False <EOL> def setUp ( self ) : <EOL> self . set_shared_copy ( '<STR_LIT>' ) <EOL> return <EOL> class TestCopyTraitsCopyNotSpecified ( CopyTraitsBase , <EOL> TestCopyTraitsSharedCopyNone ) : <EOL> __test__ = True <EOL> def setUp ( self ) : <EOL> CopyTraitsBase . setUp ( self ) <EOL> TestCopyTraitsSharedCopyNone . setUp ( self ) <EOL> self . baz2 . copy_traits ( self . baz ) <EOL> return <EOL> class TestCopyTraitsCopyShallow ( CopyTraitsBase , TestCopyTraitsSharedCopyNone ) : <EOL> __test__ = True <EOL> def setUp ( self ) : <EOL> CopyTraitsBase . setUp ( self ) <EOL> TestCopyTraitsSharedCopyNone . setUp ( self ) <EOL> self . baz2 . copy_traits ( self . baz , copy = '<STR_LIT>' ) <EOL> return <EOL> class TestCopyTraitsCopyDeep ( CopyTraitsBase , TestCopyTraitsSharedCopyNone ) : <EOL> __test__ = True <EOL> def setUp ( self ) : <EOL> CopyTraitsBase . setUp ( self ) <EOL> TestCopyTraitsSharedCopyNone . setUp ( self ) <EOL> self . baz2 . copy_traits ( self . baz , copy = '<STR_LIT>' ) <EOL> return <EOL> class CopyTraitsSharedCopyRef ( object ) : <EOL> def test_baz2_shared ( self ) : <EOL> self . assertIsNot ( self . baz2 . shared , None ) <EOL> self . assertIsNot ( self . baz2 . shared , self . shared2 ) <EOL> self . assertIs ( self . baz2 . shared , self . shared ) <EOL> def test_baz2_bar_shared ( self ) : <EOL> self . assertIsNot ( self . baz2 . bar . shared , None ) <EOL> self . assertIsNot ( self . baz2 . bar . shared , self . shared2 ) <EOL> self . assertIs ( self . baz2 . bar . shared , self . shared ) <EOL> self . assertIs ( self . baz2 . bar . shared , self . baz2 . shared ) <EOL> def test_baz2_bar_foo_shared ( self ) : <EOL> self . assertIsNot ( self . baz2 . bar . foo . shared , None ) <EOL> self . assertIsNot ( self . baz2 . bar . foo . shared , self . shared2 ) <EOL> self . assertIs ( self . baz2 . bar . foo . shared , self . shared ) <EOL> self . assertIs ( self . baz2 . bar . foo . shared , self . baz2 . shared ) <EOL> def test_baz2_bar_and_foo_shared ( self ) : <EOL> self . assertIs ( self . baz2 . bar . shared , self . baz2 . bar . foo . shared ) <EOL> self . assertIs ( self . baz2 . shared , self . baz2 . bar . foo . shared ) <EOL> class TestCopyTraitsSharedCopyRef ( CopyTraits , <EOL> CopyTraitsSharedCopyRef ) : <EOL> __test__ = False <EOL> def setUp ( self ) : <EOL> self . set_shared_copy ( '<STR_LIT>' ) <EOL> return <EOL> class TestCopyTraitsCopyNotSpecifiedSharedRef ( CopyTraitsBase , <EOL> TestCopyTraitsSharedCopyRef ) : <EOL> __test__ = True <EOL> def setUp ( self ) : <EOL> CopyTraitsBase . setUp ( self ) <EOL> TestCopyTraitsSharedCopyRef . setUp ( self ) <EOL> self . baz2 . copy_traits ( self . baz ) <EOL> return <EOL> class TestCopyTraitsCopyShallowSharedRef ( CopyTraitsBase , <EOL> TestCopyTraitsSharedCopyRef ) : <EOL> __test__ = True <EOL> def setUp ( self ) : <EOL> CopyTraitsBase . setUp ( self ) <EOL> TestCopyTraitsSharedCopyRef . setUp ( self ) <EOL> self . baz2 . copy_traits ( self . baz , copy = '<STR_LIT>' ) <EOL> return <EOL> class TestCopyTraitsCopyDeepSharedRef ( CopyTraitsBase , <EOL> TestCopyTraitsSharedCopyRef ) : <EOL> __test__ = True <EOL> def setUp ( self ) : <EOL> CopyTraitsBase . setUp ( self ) <EOL> TestCopyTraitsSharedCopyRef . setUp ( self ) <EOL> self . baz2 . copy_traits ( self . baz , copy = '<STR_LIT>' ) <EOL> return </s>
