<s> from __future__ import print_function , absolute_import , division <EOL> import os <EOL> from os . path import samefile , abspath <EOL> import tempfile <EOL> import datetime <EOL> from osprey . utils import dict_merge , in_directory <EOL> from osprey . utils import format_timedelta , current_pretty_time <EOL> def test_dict_merge_1 ( ) : <EOL> base = { '<STR_LIT:a>' : <NUM_LIT:1> } <EOL> top = { '<STR_LIT:a>' : <NUM_LIT:2> } <EOL> assert dict_merge ( base , top ) == top <EOL> def test_dict_merge_2 ( ) : <EOL> base = { '<STR_LIT:a>' : <NUM_LIT:1> } <EOL> top = { '<STR_LIT:a>' : <NUM_LIT:2> , '<STR_LIT:b>' : <NUM_LIT:3> } <EOL> assert dict_merge ( base , top ) == top <EOL> def test_dict_merge_3 ( ) : <EOL> base = { '<STR_LIT:a>' : <NUM_LIT:1> , '<STR_LIT:b>' : <NUM_LIT:2> } <EOL> top = { '<STR_LIT:a>' : <NUM_LIT:2> } <EOL> assert dict_merge ( base , top ) == { '<STR_LIT:a>' : <NUM_LIT:2> , '<STR_LIT:b>' : <NUM_LIT:2> } <EOL> def test_dict_merge_4 ( ) : <EOL> base = { '<STR_LIT:a>' : { '<STR_LIT:a>' : <NUM_LIT:1> } , '<STR_LIT:b>' : { '<STR_LIT:b>' : <NUM_LIT:2> } } <EOL> top = { '<STR_LIT:a>' : { '<STR_LIT:a>' : <NUM_LIT:2> , '<STR_LIT:b>' : <NUM_LIT:3> } } <EOL> assert dict_merge ( base , top ) == { '<STR_LIT:a>' : { '<STR_LIT:a>' : <NUM_LIT:2> , '<STR_LIT:b>' : <NUM_LIT:3> } , '<STR_LIT:b>' : { '<STR_LIT:b>' : <NUM_LIT:2> } } <EOL> def test_in_directory_1 ( ) : <EOL> tempdir = tempfile . mkdtemp ( ) <EOL> try : <EOL> initialdir = abspath ( os . curdir ) <EOL> with in_directory ( tempdir ) : <EOL> assert samefile ( abspath ( os . curdir ) , tempdir ) <EOL> assert samefile ( abspath ( os . curdir ) , initialdir ) <EOL> finally : <EOL> os . rmdir ( tempdir ) <EOL> def test_format_timedelta ( ) : <EOL> print ( format_timedelta ( datetime . timedelta ( seconds = <NUM_LIT> ) ) ) <EOL> def test_current_pretty_time ( ) : <EOL> print ( current_pretty_time ( ) ) </s>
