<s> from __future__ import absolute_import <EOL> from __future__ import unicode_literals <EOL> import os <EOL> import mock <EOL> import pytest <EOL> from compose . config . environment import Environment <EOL> from compose . config . interpolation import interpolate_environment_variables <EOL> @ pytest . yield_fixture <EOL> def mock_env ( ) : <EOL> with mock . patch . dict ( os . environ ) : <EOL> os . environ [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> os . environ [ '<STR_LIT>' ] = '<STR_LIT:bar>' <EOL> yield <EOL> def test_interpolate_environment_variables_in_services ( mock_env ) : <EOL> services = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:image>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:user>' : '<STR_LIT>' , <EOL> } <EOL> } <EOL> } <EOL> } <EOL> expected = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:image>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT:bar>' , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:user>' : '<STR_LIT>' , <EOL> } <EOL> } <EOL> } <EOL> } <EOL> assert interpolate_environment_variables ( <EOL> services , '<STR_LIT>' , Environment . from_env_file ( None ) <EOL> ) == expected <EOL> def test_interpolate_environment_variables_in_volumes ( mock_env ) : <EOL> volumes = { <EOL> '<STR_LIT:data>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : <NUM_LIT:2> , <EOL> '<STR_LIT:user>' : '<STR_LIT>' <EOL> } <EOL> } , <EOL> '<STR_LIT>' : None , <EOL> } <EOL> expected = { <EOL> '<STR_LIT:data>' : { <EOL> '<STR_LIT>' : '<STR_LIT:bar>' , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : <NUM_LIT:2> , <EOL> '<STR_LIT:user>' : '<STR_LIT>' <EOL> } <EOL> } , <EOL> '<STR_LIT>' : { } , <EOL> } <EOL> assert interpolate_environment_variables ( <EOL> volumes , '<STR_LIT>' , Environment . from_env_file ( None ) <EOL> ) == expected </s>
