Testing cosmic anisotropy with Pantheon sample and quasars at high redshifts