Skip to content

Commit

Permalink
Only test register_handler in a single thread
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Oct 26, 2024
1 parent 64eed14 commit 60bf46f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
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_save(tmp_path: Path) -> None:


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

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_save(tmp_path: Path) -> None:


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

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_save() -> None:


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

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 @@ def test_load() -> None:
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))

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

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

0 comments on commit 60bf46f

Please sign in to comment.