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

Unit test fails under Python 3.13 #5035

Closed
fedepell opened this issue Jan 25, 2024 · 1 comment · Fixed by #5037
Closed

Unit test fails under Python 3.13 #5035

fedepell opened this issue Jan 25, 2024 · 1 comment · Fixed by #5037
Labels
Milestone

Comments

@fedepell
Copy link
Contributor

In Fedora we have RobotFramework tests running for upcoming Fedora 41 using Python 3.13.03 in a side tag.
While running the unit tests (version 7.0) I have a new failure in utils:

FAIL: test_remove_entries_with_lambda_and_multiple_entries
(test_error.TestRemoveRobotEntriesFromTraceback.test_remove_entries_with_lambda_and_multiple_entries)
----------------------------------------------------------------------
======================================================================
FAIL: test_remove_entries_with_lambda_and_multiple_entries (test_error.TestRemoveRobotEntriesFromTraceback.test_remove_entries_with_lambda_and_multiple_entries)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/robotframework-7.0/utest/utils/test_error.py", line 107, in test_remove_entries_with_lambda_and_multiple_entries
            self._verify_traceback(r'''
            ~~~~~~~~~~~~~~~~~~~~~~^^^^^
    Traceback \(most recent call last\):
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
        1/0
        ^^^
    '''.strip(), assert_raises, AssertionError, raising_lambda)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/robotframework-7.0/utest/utils/test_error.py", line 133, in _verify_traceback
    raise AssertionError('\nExpected:\n%s\n\nActual:\n%s' % (expected, tb))
AssertionError: 
Expected:
Traceback \(most recent call last\):
  File ".*", line \d+, in <lambda.*>
    raising_lambda = lambda: raises\(\)
  File ".*", line \d+, in raises
    1/0

Actual:
Traceback (most recent call last):
  File "/builddir/build/BUILD/robotframework-7.0/utest/utils/test_error.py", line 106, in <lambda>
    raising_lambda = lambda: raises()
                             ~~~~~~^^
  File "/builddir/build/BUILD/robotframework-7.0/utest/utils/test_error.py", line 105, in raises
    1/0
    ~^~
ZeroDivisionError: division by zero

----------------------------------------------------------------------
Ran 635 tests in 0.577s

FAILED (failures=1)

Looking at the output and playing a bit around the solution to me looks like changing the test filter (line in test_error.py) from:

        # Remove lines indicating error location with `^^^^` used by Python 3.11+.
        tb = '\n'.join(line for line in tb.splitlines() if line.strip('^ '))

To:

        # Remove lines indicating error location with `^^^^` used by Python 3.11+ and `~~~~^` variants in Python 3.13+.
        tb = '\n'.join(line for line in tb.splitlines() if line.strip('^~ '))

Which filters also the error indicators with ~ that seem to be new.

This makes the test pass, I hope/believe without breaking in previous versions.

If the proposal makes sense I can of course open a MR!

Thanks!
F.

@pekkaklarck
Copy link
Member

The fix looks good to me. There will probably be more work to fully support Python 3.13 (removal of telnetlib is likely to cause problems), but getting this issue fixed already now is anyway a good idea. I've typically started testing with new Python versions when they are in beta.

@pekkaklarck pekkaklarck added this to the v7.0.1 milestone Jan 28, 2024
@pekkaklarck pekkaklarck added bug priority: low acknowledge To be acknowledged in release notes effort: small labels Jan 28, 2024
@pekkaklarck pekkaklarck changed the title Test fails under Python 3.13 Unit test fails under Python 3.13 Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants