Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only test register_handler in a single thread #8501

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Tests/test_file_bufrstub.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@


def test_handler(tmp_path: Path) -> None:
if BufrStubImagePlugin._handler is not None:
return

Check warning on line 55 in Tests/test_file_bufrstub.py

View check run for this annotation

Codecov / codecov/patch

Tests/test_file_bufrstub.py#L55

Added line #L55 was not covered by tests

class TestHandler(ImageFile.StubHandler):
opened = False
loaded = False
Expand Down
3 changes: 3 additions & 0 deletions Tests/test_file_gribstub.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@


def test_handler(tmp_path: Path) -> None:
if GribStubImagePlugin._handler is not None:
return

Check warning on line 55 in Tests/test_file_gribstub.py

View check run for this annotation

Codecov / codecov/patch

Tests/test_file_gribstub.py#L55

Added line #L55 was not covered by tests

class TestHandler(ImageFile.StubHandler):
opened = False
loaded = False
Expand Down
3 changes: 3 additions & 0 deletions Tests/test_file_hdf5stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@


def test_handler(tmp_path: Path) -> None:
if Hdf5StubImagePlugin._handler is not None:
return

Check warning on line 57 in Tests/test_file_hdf5stub.py

View check run for this annotation

Codecov / codecov/patch

Tests/test_file_hdf5stub.py#L57

Added line #L57 was not covered by tests

class TestHandler(ImageFile.StubHandler):
opened = False
loaded = False
Expand Down
18 changes: 11 additions & 7 deletions Tests/test_file_wmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,19 @@
assert im.load()[0, 0] == (255, 255, 255)


def test_register_handler(tmp_path: Path) -> None:
class TestHandler(ImageFile.StubHandler):
methodCalled = False
class TestHandler(ImageFile.StubHandler):
methodCalled = False

def load(self, im: ImageFile.StubImageFile) -> Image.Image:
return Image.new("RGB", (1, 1))

Check warning on line 41 in Tests/test_file_wmf.py

View check run for this annotation

Codecov / codecov/patch

Tests/test_file_wmf.py#L41

Added line #L41 was not covered by tests

def load(self, im: ImageFile.StubImageFile) -> Image.Image:
return Image.new("RGB", (1, 1))
def save(self, im: Image.Image, fp: IO[bytes], filename: str) -> None:
self.methodCalled = True

def save(self, im: Image.Image, fp: IO[bytes], filename: str) -> None:
self.methodCalled = True

def test_register_handler(tmp_path: Path) -> None:
if isinstance(WmfImagePlugin._handler, TestHandler):
return

Check warning on line 49 in Tests/test_file_wmf.py

View check run for this annotation

Codecov / codecov/patch

Tests/test_file_wmf.py#L49

Added line #L49 was not covered by tests

handler = TestHandler()
original_handler = WmfImagePlugin._handler
Expand Down
Loading