def test_patch_unpatch(self):
    patch()
    patch()
    service = 'fo'
    conn = self._get_conn(service=service)
    conn.cursor().execute("select 'blah'")
    self.assert_structure(dict(name='postgres.query', service=service))
    self.reset()
    unpatch()
    conn = self._get_conn()
    conn.cursor().execute("select 'blah'")
    self.assert_has_no_spans()
    patch()
    conn = self._get_conn(service=service)
    conn.cursor().execute("select 'blah'")
    self.assert_structure(dict(name='postgres.query', service=service))
def test_patch_unpatch(self):
    patch()
    patch()
    service = 'fo'
    conn = self._get_conn(service=service)
    conn.cursor().execute("select 'blah'")
    self.assert_structure(dict(name='postgres.query', service=service))
    self.reset()
    unpatch()
    conn = self._get_conn()
    conn.cursor().execute("select 'blah'")
    self.assert_has_no_spans()
    patch()
    conn = self._get_conn(service=service)
    conn.cursor().execute("select 'blah'")
    self.assert_structure(dict(name='postgres.query', service=service))