The port authority spider is using the self.year field from the CityScrapersSpider parent class, which is initialized based on the current date time in the CityScrapersSpider constructor. Therefore, the scraper construction needs to happen within the bounds of freezer.start()/freezer.end() in the test case in order for self.year to be affected by the mock.
And running YAPF for good measure
The port authority spider is using the
self.year
field from theCityScrapersSpider
parent class, which is initialized based on the current date time in theCityScrapersSpider
constructor. Therefore, the scraper construction needs to happen within the bounds offreezer.start()/freezer.end()
in the test case in order forself.year
to be affected by the mock.