Skip to content

ledmatrix-flights: 4 map-cache tests fail — fake_fetch double is missing the allow_network keyword #465

Description

@ChuckBuilds

Summary

Four tests in ledmatrix-flights/test_vegas_map_parity.py fail on main. The test's tile-fetch stand-in has not kept up with the function it replaces: _fetch_tile gained an allow_network keyword, fake_fetch still takes three positional arguments.

E   TypeError: enable_map_background.<locals>.fake_fetch() got an unexpected keyword argument 'allow_network'
    manager.py:2317

Reproduction

cd ~/LEDMatrix
PYTHONPATH=$PWD LEDMATRIX_CORE=$PWD python3 -m pytest \
  plugin-repos/ledmatrix-flights/test_vegas_map_parity.py -q
4 failed, 17 passed in 0.68s

FAILED ...::TestMapBackgroundCacheIsSizeAware::test_background_matches_the_requested_size_after_a_narrower_render
FAILED ...::TestMapBackgroundCacheIsSizeAware::test_each_size_is_still_cached
FAILED ...::TestMapBackgroundCacheIsSizeAware::test_moving_the_centre_drops_every_cached_size
FAILED ...::TestMapBackgroundCacheIsSizeAware::test_rendered_map_is_the_display_size_across_a_size_switch

The mismatch

plugins/ledmatrix-flights/manager.py:2101 — the real signature:

def _fetch_tile(self, x, y, zoom, allow_network: bool = True) -> Optional[Image.Image]:
    """...allow_network=False serves the cache only and never opens a socket."""

and it is called with the keyword at manager.py:2087:

if self._fetch_tile(x, y, zoom, allow_network=True) is not None:

plugins/ledmatrix-flights/test_vegas_map_parity.py:264 — the stand-in:

def fake_fetch(x, y, zoom):
    calls.append((x, y, zoom))

So every path that reaches the keyword call raises. All four failures are in TestMapBackgroundCacheIsSizeAware, i.e. exactly the size-aware caching this file exists to protect.

Why it went unnoticed

The file is a pytest module with no __main__ guard, and scripts/run_plugin_tests.py runs discovered files as scripts and reads the exit code. Importing a pytest module runs no tests and exits 0, so CI has been reporting this file as passing. Filed separately as the runner bug.

Suggested fix

Accept and record the keyword, so the double keeps testing what the caller actually does:

def fake_fetch(x, y, zoom, allow_network=True):
    calls.append((x, y, zoom))

If any of these tests should be asserting that the cache-only path passes allow_network=False, that is worth capturing in calls while you are in there — the parameter exists precisely so a render can be served without opening a socket, and nothing currently checks it.

This is the third stale hand-built test double found in this repo recently (see also the _font_cache fixture in baseball-scoreboard and _Ticker in odds-ticker), which might argue for asserting double/real signature compatibility in CI rather than fixing them one at a time.

Environment

main (verified the mismatch is present upstream, not a local artifact), pytest 9.1.1, 44 first-party plugins installed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions