Best Python code snippet using avocado_python
test_file_tar.py
Source:test_file_tar.py
1import warnings2import pytest3from PIL import Image, TarIO, features4from .helper import is_pypy5# Sample tar archive6TEST_TAR_FILE = "Tests/images/hopper.tar"7def test_sanity():8 for codec, test_path, format in [9 ["zlib", "hopper.png", "PNG"],10 ["jpg", "hopper.jpg", "JPEG"],11 ]:12 if features.check(codec):13 with TarIO.TarIO(TEST_TAR_FILE, test_path) as tar:14 with Image.open(tar) as im:15 im.load()16 assert im.mode == "RGB"17 assert im.size == (128, 128)18 assert im.format == format19@pytest.mark.skipif(is_pypy(), reason="Requires CPython")20def test_unclosed_file():21 def open():22 TarIO.TarIO(TEST_TAR_FILE, "hopper.jpg")23 pytest.warns(ResourceWarning, open)24def test_close():25 with warnings.catch_warnings():26 tar = TarIO.TarIO(TEST_TAR_FILE, "hopper.jpg")27 tar.close()28def test_contextmanager():29 with warnings.catch_warnings():30 with TarIO.TarIO(TEST_TAR_FILE, "hopper.jpg"):...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!