'Common code for chown, fchown and lchown tests.'

def _test_all_chown_common(self, chown_func, first_param):

    if (os.getuid() == 0):
        try:
            ent = pwd.getpwnam('nfsnobody')
            chown_func(first_param, ent.pw_uid, ent.pw_gid)
        except KeyError:
            pass
    else:
        self.assertRaises(OSError, chown_func, first_param, 0, 0)
    chown_func(first_param, os.getuid(), os.getgid())
