<s> import unittest <EOL> from mockfs import util <EOL> class MockFSUtilTestCase ( unittest . TestCase ) : <EOL> def test_sanitize ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( util . sanitize ( '<STR_LIT>' ) , '<STR_LIT:/>' ) <EOL> self . assertEqual ( util . sanitize ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> self . assertEqual ( util . sanitize ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> def test_build_nested_dict ( self ) : <EOL> nested = util . build_nested_dict ( { '<STR_LIT>' : '<STR_LIT:bar>' , <EOL> '<STR_LIT>' : '<STR_LIT:c>' } ) <EOL> self . assertEqual ( nested [ '<STR_LIT:foo>' ] , '<STR_LIT:bar>' ) <EOL> self . assertEqual ( nested [ '<STR_LIT:a>' ] , { '<STR_LIT:b>' : { '<STR_LIT:c>' : '<STR_LIT:c>' } } ) <EOL> def test_build_nested_dir_dict ( self ) : <EOL> nested = util . build_nested_dir_dict ( '<STR_LIT>' ) <EOL> self . assertEqual ( nested [ '<STR_LIT:foo>' ] , { } ) <EOL> nested = util . build_nested_dir_dict ( '<STR_LIT>' ) <EOL> self . assertEqual ( nested [ '<STR_LIT:bar>' ] [ '<STR_LIT>' ] , { } ) <EOL> def test_merge_extends_lists ( self ) : <EOL> a = { '<STR_LIT:a>' : [ <NUM_LIT:1> , <NUM_LIT:2> ] } <EOL> b = { '<STR_LIT:a>' : [ <NUM_LIT:3> , <NUM_LIT:4> ] } <EOL> util . merge_dicts ( a , b ) <EOL> self . assertEqual ( b [ '<STR_LIT:a>' ] , [ <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> def test_merge_overrides ( self ) : <EOL> a = { '<STR_LIT:a>' : <NUM_LIT:1> } <EOL> b = { '<STR_LIT:a>' : <NUM_LIT:2> } <EOL> util . merge_dicts ( a , b ) <EOL> self . assertEqual ( b [ '<STR_LIT:a>' ] , <NUM_LIT:1> ) <EOL> def test_merge_no_overlap ( self ) : <EOL> a = { '<STR_LIT:a>' : <NUM_LIT:1> } <EOL> b = { '<STR_LIT:b>' : <NUM_LIT:2> } <EOL> util . merge_dicts ( a , b ) <EOL> self . assertEqual ( b [ '<STR_LIT:a>' ] , <NUM_LIT:1> ) <EOL> self . assertEqual ( b [ '<STR_LIT:b>' ] , <NUM_LIT:2> ) <EOL> def test_merge_conflict_dicts ( self ) : <EOL> src = { '<STR_LIT:a>' : { '<STR_LIT:b>' : '<STR_LIT:src>' } } <EOL> dst = { '<STR_LIT:a>' : { '<STR_LIT:b>' : '<STR_LIT>' } } <EOL> util . merge_dicts ( src , dst ) <EOL> self . assertEqual ( dst [ '<STR_LIT:a>' ] [ '<STR_LIT:b>' ] , '<STR_LIT:src>' ) <EOL> def suite ( ) : <EOL> suite = unittest . TestSuite ( ) <EOL> suite . addTest ( unittest . makeSuite ( MockFSUtilTestCase ) ) <EOL> return suite <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
