A test will fail if it raises any kind of unexpected Exception. You can just invoke foo(7) and you will have tested that no MyError is raised. So, following will suffice:
def test_foo3():
foo(7)
If you want to be explicit and write an assert statement for this, you can do:
def test_foo3():
try:
foo(7)
except MyError:
pytest.fail("Unexpected MyError ..")