rstcheck / rstcheck-core

Core library behind rstcheck.
http://rstcheck-core.rtfd.io/
MIT License
4 stars 8 forks source link

[Bug]: Failing test on python 3.12: `TestCodeBlockChecker.test_check_python_returns_error_on_syntax_warning` #57

Closed sanjayankur31 closed 1 year ago

sanjayankur31 commented 1 year ago

To Dos

Example Code (python)

While building the package on Fedora, we're seeing this one test fail.

Relevant log output

+ /usr/bin/pytest
============================= test session starts ==============================
platform linux -- Python 3.12.0rc1, pytest-7.4.0, pluggy-1.2.0
rootdir: /builddir/build/BUILD/rstcheck_core-1.0.3
configfile: pyproject.toml
plugins: mock-3.11.1
collected 458 items

tests/test__docutils.py ....s.....                                       [  2%]
tests/test__extras.py .ss.s.s.                                           [  3%]
tests/test__sphinx.py s.s.ssssssss                                       [  6%]
tests/test_checker.py ..............ss.s..sss...ssssss...sss...........s [ 17%]
..s.sF.............ss..ss..ss..ss.ss...                                  [ 25%]
tests/test_config.py ................................................... [ 37%]
...............................................................sssssssss [ 52%]
sssssssssssssss.....sss.....ssss.sss...................                  [ 64%]
tests/test_inline_config.py ....................                         [ 69%]
tests/test_runner.py ..ssssss...................................         [ 78%]
tests/test_types.py ..                                                   [ 79%]
tests/integration_tests/test_file_checker.py ......................s..s. [ 84%]
s.........s..s.s.                                                        [ 88%]
tests/integration_tests/test_runner.py ..........................s..s.s. [ 95%]
............s..s.s.                                                      [100%]

=================================== FAILURES ===================================
____ TestCodeBlockChecker.test_check_python_returns_error_on_syntax_warning ____

        @staticmethod
        @pytest.mark.skipif(sys.version_info < (3, 8), reason="Requires python3.8 or higher")
        def test_check_python_returns_error_on_syntax_warning() -> None:
            """Test ``check_python`` returns error on SyntaxWarning.

            With python 3.8 a SyntaxWarning is logged for '"is" with literals'.

            Context: https://github.com/rstcheck/rstcheck/issues/122
            """
            source = """
    if mystring is "ok":
        ...
    """
            cb_checker = checker.CodeBlockChecker("<string>")

            result = list(cb_checker.check_python(source))

            assert len(result) == 1
>           assert '"is" with a literal' in result[0]["message"]
E           assert '"is" with a literal' in '"is" with \'str\' literal. Did you mean "=="?'

cb_checker = <rstcheck_core.checker.CodeBlockChecker object at 0x7fda444f5400>
result     = [{'line_number': 2, 'message': '"is" with \'str\' literal. Did you mean "=="?', 'source_origin': '<string>'}]
source     = '\nif mystring is "ok":\n    ...\n'

tests/test_checker.py:735: AssertionError

Description

While building the package on Fedora, we're seeing this one test fail.

Downstream report: https://bugzilla.redhat.com/show_bug.cgi?id=2226320

Operating System

Linux

Operating System Details

No response

Python Version

3.12.0rc1

rstcheck Version

1.0.3

Additional Context

No response

Cielquan commented 1 year ago

I guess a new test case needs to be added for the new py3.12 error message.