Assert all([d is data[0] for d in data]) error

The first measure does not make sense, as you haven’t provided any integration data.

Secondly, if you want to use the measures in the same form, I suggest doing:

dx = ufl.Measure("dx", domain=mesh, subdomain_data=markers)
dx_s = dx(1)

Here, calling something with dx will integrate over the whole domain, while dx(1) will integrate over those cells marked with 1.

Please avoid posting duplicate questions, as (Subtraction between form on the whole domain and the form on a subdomain) is more or less the same question).