tests that rely on residuals This might be an r question, which I think is not allowed here, but I figured I would try in case it is ok. There are a series of tests which as I understand it rely on residuals. One example of this is the Breusch-Pagan test. This generates apparent results from that (and the documentation seems to require a regression model rather than residuals).
# load the dataset
data(mtcars)
# fit a regression model
model <- lm(mpg~disp+hp, data=mtcars)
library(lmtest)
# perform Breusch-Pagan Test
bptest(model)

Is the code extracting the residuals or am I wrong in assuming you need residuals for this test (the comments I read seem pretty clear it is run on the residuals).
 A: To add to @ChristophHanck's comment, you can check the source code for bptest and in it you see that a formula and a data frame can be applied:
bptest(mpg~disp+hp, data=mtcars)

studentized Breusch-Pagan test

data:  mpg ~ disp + hp
BP = 4.0861, df = 2, p-value = 0.1296

Underneath the code, there's two parts. If you provide a lm object, it will extract the x and y, refit the formula using lm.fit. After which, it extracts the residuals from the lm.fit object and calculates the relevant statistics. These are the relevant lines:
resi <- lm.fit(X,y)$residuals
  sigma2 <- sum(resi^2)/n

  if(studentize)
  {
    w <- resi^2 - sigma2
    aux <- lm.fit(Z, w)    
    bp <- n * sum(aux$fitted.values^2)/sum(w^2)
    method <- "studentized Breusch-Pagan test"
  }
  else
  {
    f <- resi^2/sigma2 -1
    aux <- lm.fit(Z, f)
    bp <- 0.5 * sum(aux$fitted.values^2)
    method <- "Breusch-Pagan test"
  }

  names(bp) <- "BP"
  df <- c("df" = aux$rank - 1)
  RVAL <- list(statistic = bp,
      parameter = df,
      method = method,
      p.value= pchisq(bp, df, lower.tail = FALSE),
      data.name = dname)

