Skip to content

bpython.test.test_interpreter.TestInterpreter.test_syntaxerror fails (bpython 0.22.1) #952

Closed
@mcepl

Description

@mcepl

When packaging 0.22.1 for openSUSE I get this failure in the test suite run:

[   28s] ======================================================================
[   28s] FAIL: test_syntaxerror (bpython.test.test_interpreter.TestInterpreter)
[   28s] ----------------------------------------------------------------------
[   28s] Traceback (most recent call last):
[   28s]   File "/home/abuild/rpmbuild/BUILD/bpython-0.22.1/bpython/test/test_interpreter.py", line 87, in test_syntaxerror
[   28s]     self.assertMultiLineEqual(str(plain("").join(a)), str(expected))
[   28s] AssertionError: '  Fi[92 chars]n       ^^\n\x1b[31m\x1b[1mSyntaxError\x1b[0m\[37 chars]9m\n' != '  Fi[92 chars]n    ^^^^^\n\x1b[31m\x1b[1mSyntaxError\x1b[0m\[66 chars]9m\n'
[   28s]     File "<bpython-input-148>", line 1
[   28s]       1.1.1.1
[   28s] -        ^^
[   28s] +     ^^^^^
[   28s] - SyntaxError: invalid syntax
[   28s] + SyntaxError: invalid syntax. Perhaps you forgot a comma?
[   28s] ?                                                   +++++++++++++++++++++++++++++
[   28s] 
[   28s] 
[   28s] ----------------------------------------------------------------------
[   28s] Ran 321 tests in 2.776s
[   28s] 
[   28s] FAILED (failures=1, skipped=20, expected failures=3)
[   28s] tmp6b65mybw
[   28s] tmpmoudgnm3
[   28s] 
[   28s] import inspect
[   28s] 
[   28s] class TestCls:
[   28s]     # A class with boring __init__ typing
[   28s]     def __init__(self, *args, **kwargs):
[   28s]         pass
[   28s]     # But that uses super exotic typings recognized by inspect.signature
[   28s]     __signature__ = inspect.Signature([
[   28s]         inspect.Parameter("apple", inspect.Parameter.POSITIONAL_ONLY),
[   28s]         inspect.Parameter("apple2", inspect.Parameter.KEYWORD_ONLY),
[   28s]         inspect.Parameter("pinetree", inspect.Parameter.KEYWORD_ONLY),
[   28s]     ])

It seems to me that this patch fixes the problem:

---
 bpython/test/test_interpreter.py |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/bpython/test/test_interpreter.py
+++ b/bpython/test/test_interpreter.py
@@ -41,10 +41,10 @@ class TestInterpreter(unittest.TestCase)
                 + green('"<bpython-input-148>"')
                 + ", line "
                 + bold(magenta("1"))
-                + "\n    1.1.1.1\n    ^^^^^\n"
+                + "\n    1.1.1.1\n       ^^\n"
                 + bold(red("SyntaxError"))
                 + ": "
-                + cyan("invalid syntax. Perhaps you forgot a comma?")
+                + cyan("invalid syntax")
                 + "\n"
             )
         elif (3, 8) <= sys.version_info[:2] <= (3, 9):

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions