示例#1
0
    def test_register_handler(self):
        class TestHandler:
            methodCalled = False

            def save(self, im, fp, filename):
                self.methodCalled = True
        handler = TestHandler()
        WmfImagePlugin.register_handler(handler)

        im = hopper()
        tmpfile = self.tempfile("temp.wmf")
        im.save(tmpfile)
        self.assertTrue(handler.methodCalled)

        # Restore the state before this test
        WmfImagePlugin.register_handler(None)
示例#2
0
    def test_register_handler(self):
        class TestHandler:
            methodCalled = False

            def save(self, im, fp, filename):
                self.methodCalled = True
        handler = TestHandler()
        WmfImagePlugin.register_handler(handler)

        im = hopper()
        tmpfile = self.tempfile("temp.wmf")
        im.save(tmpfile)
        self.assertTrue(handler.methodCalled)

        # Restore the state before this test
        WmfImagePlugin.register_handler(None)
示例#3
0
def test_register_handler(tmp_path):
    class TestHandler:
        methodCalled = False

        def save(self, im, fp, filename):
            self.methodCalled = True

    handler = TestHandler()
    original_handler = WmfImagePlugin._handler
    WmfImagePlugin.register_handler(handler)

    im = hopper()
    tmpfile = str(tmp_path / "temp.wmf")
    im.save(tmpfile)
    assert handler.methodCalled

    # Restore the state before this test
    WmfImagePlugin.register_handler(original_handler)