def test_delete_mount_point(self): """Unit test for deleting a mount point in use""" if not sudo_mode() or os.getuid() > 0: self.skipTest('not enough privileges') from_dir = os.path.join(self.tempdir, 'mount_from') to_dir = os.path.join(self.tempdir, 'mount_to') os.mkdir(from_dir) os.mkdir(to_dir) args = ['mount', '--bind', from_dir, to_dir] (rc, stdout, stderr) = run_external(args) msg = 'error calling mount\nargs=%s\nstderr=%s' % (args, stderr) self.assertEqual(rc, 0, msg) delete(to_dir) args = ['umount', to_dir] (rc, stdout, stderr) = run_external(args) msg = 'error calling umount\nargs=%s\nstderr=%s' % (args, stderr) self.assertEqual(rc, 0, msg)
def have_root(): """Return true if we have root privileges on POSIX systems""" return sudo_mode() or os.getuid() == 0