def test_saveAnyDataTo(self): m = mock_open() with patch("builtins.open", m, create=True) as mock_file: with patch('os.path.isdir') as dir_mock: dir_mock.return_value = lambda x: True FileHandler.saveAnyDataTo("test data", 'abc/images.jpg') m.assert_called_with('abc/images.jpg', 'wb+')
def saveTo(self, dir=os.path.join(ROOT_DIR, 'downloads')): # by default the images are stored in a <root>/downloads folder self.dir = dir for image, fileName in self.getImages(): if image is None: continue FileHandler.saveAnyDataTo(image.content, os.path.join(self.dir, fileName))