Do teachers mark some pupils more generously than others? We propose a new approach to this longstanding question, by exploiting a unique situation where teachers were required to assign grades and the rankings of students within grades for a high-stakes assessment. We use this to test for imbalance of student characteristics across grade boundaries by comparing the top ranked students of one grade, to the lowest ranking students of the next grade. Due to the discrete nature of ranks, we implement an extension to the RDD framework called local randomisation. This does not require the standard assumptions used in teacher bias literature. We find evidence of teacher generosity on average favouring higher income, female, white students. However, there is large variation in gender bias across subjects. Teachers tend to favour a gender more the less that gender is represented in a subject.