def find_in_migration(self, anchor, needles, terminus='\n', distance=None):
        # The anchor must exist. If it doesn't, we have another problem.
        assert anchor in self.migration_code, 'Could not find: %s\nIn: %s' % (
            anchor, self.migration_code,
        )
        start = self.migration_code.index(anchor) + len(anchor)

        # If a distance is provided, get the substring based on it.
        # Otherwise, use the terminus.
        if distance:
            block = self.migration_code[start:start + distance]
        else:
            try:
                end = self.migration_code.index(terminus, start)
            except ValueError:
                end = None
            block = self.migration_code[start:end]

        # Assert that each of my expected needles is found in the
        # given haystack.
        for needle in needles:
            assert needle in block, 'Could not find text:\n%s' % needle
Send a command to the pa server using a socket.
dataset/ETHPy150Open lukesneeringer/django-pgfields/tests/south_migrations/tests.py/MigrationCreationSuite.find_in_migration--crossover with--dataset/ETHPy150Open home-assistant/home-assistant/homeassistant/components/switch/pulseaudio_loopback.py/PAServer._send_command