Why did this work outside py.test?