Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider preventing multiple lines in split_before_newlines #10

Open
Poikilos opened this issue Aug 22, 2023 · 0 comments
Open

Consider preventing multiple lines in split_before_newlines #10

Poikilos opened this issue Aug 22, 2023 · 0 comments

Comments

@Poikilos
Copy link
Contributor

Probably not, but would require the test change (in str and bytes versions of the test):

replace:

                self.assertEqual(split_before_newlines(" a\n "), (" a", "\n "))
                self.assertEqual(split_before_newlines("a \n "), ("a ", "\n "))

with

        # Pairs that should be rejected (allowing more lines causes more complexity)
        bad_pairs = [
            (" a\n ", (" a", "\n ")),
            ("a \n ", ("a ", "\n ")),
        ]
        for bad_pair in bad_pairs:
            arg, goodTuple = bad_pair
            good_exception = False
            try:
                self.assertEqual(split_before_newlines(arg), goodTuple)
            except ValueError as ex:
                if "more than one line" in str(ex):
                    good_exception = True
                else:
                    raise
            if not good_exception:
                raise AssertionError(
                    "split_before_newlines should reject more than one line"
                )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant