diff --git a/kwant/continuum/tests/test_common.py b/kwant/continuum/tests/test_common.py
index 298495c9cb98b068d592fef453f9b2c5e9cee53d..34981d6943dceb2a1cc020aa3fe76d1300b93faf 100644
--- a/kwant/continuum/tests/test_common.py
+++ b/kwant/continuum/tests/test_common.py
@@ -185,5 +185,12 @@ def test_lambdify_substitutions(e, kwargs):
     should_be = lambda x, y, z: x + y + z
     subs = {'y': 'y + z'}
 
-    e = lambdify(e, locals=subs)
+    if not isinstance(e, str):
+        # warns that 'locals' are not used if 'e' is
+        # a sympy expression already
+        with pytest.warns(RuntimeWarning):
+            e = lambdify(e, locals=subs)
+    else:
+        e = lambdify(e, locals=subs)
+
     assert e(**kwargs) == should_be(**kwargs)