def METHOD_NAME(self, environ):
    expected_name = 'some_name'
    environ.get.return_value = None
    if pwd:
        with mock.patch('os.getuid') as uid, \
                mock.patch('pwd.getpwuid') as getpw:
            uid.return_value = 42
            getpw.return_value = [expected_name]
            self.assertEqual(expected_name,
                             getpass.getuser())
            getpw.assert_called_once_with(42)
    else:
        self.assertRaises(ImportError, getpass.getuser)