def filesize(self) -> int: """File size of the media stream in bytes. :rtype: int :returns: Filesize (in bytes) of the stream. """ if self._filesize is None: headers = request.head(self.url) self._filesize = int(headers["content-length"]) return self._filesize
def test_headers(mock_urlopen): response = mock.Mock() response.info.return_value = {"content-length": "16384"} mock_urlopen.return_value = response response = request.head("http://fakeassurl.gov") assert response == {"content-length": "16384"}