Testing

city_scrapers_core.utils.file_response(file_name, mode='r', url=None)[source]

Create a Scrapy fake HTTP response from a HTML file. Based on https://stackoverflow.com/a/12741030

Parameters
  • file_name (str) – The relative or absolute filename from the tests directory

  • url (Optional[str]) – The URL of the response

  • mode (str) – The mode the file should be opened with, defaults to “r”

Return type

Union[Response, HtmlResponse, TextResponse]

Returns

A scrapy HTTP response which can be used for testing