  We present a general framework for contextuality tests in phase space using
displacement operators. First, we derive a general condition that a single-mode
displacement operator should fulfill in order to construct Peres-Mermin square
and similar scenarios. This approach offers a straightforward scheme for
experimental implementations of the tests via modular variable measurements. In
addition to the continuous variable case, our condition can also be applied to
finite-dimensional systems in discrete phase space, using Heisenberg-Weyl
operators. This approach, therefore, offers a unified picture of contextuality
with a geometric flavor.
