Skip to content

Instantly share code, notes, and snippets.

@Ram-Z
Created February 18, 2015 13:50
Show Gist options
  • Save Ram-Z/65195c92bbdce36320c1 to your computer and use it in GitHub Desktop.
Save Ram-Z/65195c92bbdce36320c1 to your computer and use it in GitHub Desktop.
def test_validate_expanduser(self, os_path):
"""Test if validate expands the user correctly."""
# os_path.expandvars.side_effect = lambda x: x.replace('$BAR',
# '/home/foo/bar')
os_path.expandvars = os.path.expandvars
os_path.expanduser.side_effect = lambda x: x.replace('~', '/home/foo')
os_path.isdir.side_effect = lambda path: path == '/home/foo/foobar'
os_path.isabs.return_value = True
with helpers.environ_set_temp('FOO', 'foo'):
self.t.validate('~/foobar')
os_path.expanduser.assert_called_once_with('~/foobar')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment