def METHOD_NAME(self):
    with tempfile.NamedTemporaryFile(delete=False) as file:
        pass
    try:
        for path in file.name, pathlib.Path(file.name):
            for config in {}, self.custom_config:
                Example(**self.data).to_json(path, **config)
                expected = json.dumps(self.data, **(config or self.default_config))
                with open(path, encoding='UTF-8') as file:
                    assert_equal(file.read(), expected)
    finally:
        os.remove(file.name)