Issue 1989: Convert null values to empty strings in popup and tooltip by hansthen · Pull Request #2134 · python-visualization/folium

@hansthen

@hansthen

@hansthen hansthen changed the title Special case null values in popup and tooltip Issue 1989: Convert null values to empty strings in popup and tooltip

Apr 19, 2025

@hansthen

@ocefpaf

Can we add a test to avoid regression? Maybe ask in #1989 for some code/file we can use?

@hansthen

Can we add a test to avoid regression? Maybe ask in #1989 for some code/file we can use?

I wrote a small program to visually test this. But since this is behavior in the generated code, it is difficult to test with our current tests frameworks.

I have a few ideas on how to make visual snapshots and compare against those during tests. Is it okay if I work on snapshot / regression testing in a new branch?

@ocefpaf

I have a few ideas on how to make visual snapshots and compare against those during tests.

We can use https://github.com/matplotlib/pytest-mpl. I had some success with it in the past. However, we can try a text based text that checks if the HTML has null in those fields.

Is it okay if I work on snapshot / regression testing in a new branch?

Sure. IMO it is OK to merge as-is and we can open an issue for further testing here.

@hansthen

However, we can try a text based text that checks if the HTML has null in those fields.

It's not so easy. The null values are still there. We just filter them in javascript when we generate the popup.

    let handleObject = feature => {
        if (feature === null) {
            return '';
        } else if (typeof(feature)=='object') {
            return JSON.stringify(feature);
        } else {
            return feature;
        }
    }

I can of course create to test that specific string, but that would feel a bit pointless.

@hansthen

I created an issue for the regression tests. #2140

@ocefpaf

I can of course create to test that specific string, but that would feel a bit pointless.

Indeed. Let's merge and focus on the image comparison test in the future.