async def test_space_preservation(self):
        """Test preservation of leading and trailing spaces (for
        word-by-word streaming in bot-tts-text).
        """
        input_text = [
            "  Leading spaces",
            "Trailing spaces  ",
            "  Both ends  ",
            "  Multiple  spaces  between  words  ",
        ]

        for text in input_text:
            result = await self.filter.filter(text)
            self.assertEqual(
                len(result), len(text), f"Space preservation failed for: '{text}'\nGot: '{result}'"
            )
            # Check if spaces are in the same positions
            for i, char in enumerate(text):
                if char == " ":
                    self.assertEqual(
                        result[i], " ", f"Space at position {i} was not preserved in: '{text}'"
                    )
Test preservation of leading and trailing spaces (for
        word-by-word streaming in bot-tts-text).
        
tests/test_markdown_text_filter.py