Bug 2196749 - python-pysnooper fails to build with Python 3.12: OutputFailure: tests ouputs differs from expectations
Summary: python-pysnooper fails to build with Python 3.12: OutputFailure: tests ouputs...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: python-pysnooper
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Zbigniew Jędrzejewski-Szmek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.12
TreeView+ depends on / blocked
 
Reported: 2023-05-10 06:20 UTC by Tomáš Hrnčiar
Modified: 2023-07-16 10:48 UTC (History)
5 users (show)

Fixed In Version: python-pysnooper-1.2.0-1.fc39
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-07-16 10:48:55 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Tomáš Hrnčiar 2023-05-10 06:20:14 UTC
python-pysnooper fails to build with Python 3.12.0a7.

The log is very long, see the log for other test failures. 

____ test_snooping_on_class_does_not_cause_base_class_to_be_snooped[False] _____

normalize = False

    @pytest.mark.parametrize("normalize", (True, False))
    def test_snooping_on_class_does_not_cause_base_class_to_be_snooped(normalize):
        string_io = io.StringIO()
    
        class UnsnoopedBaseClass(object):
            def __init__(self):
                self.method_on_base_class_was_called = False
    
            def method_on_base_class(self):
                self.method_on_base_class_was_called = True
    
        @pysnooper.snoop(string_io, normalize=normalize, color=False)
        class MyClass(UnsnoopedBaseClass):
            def method_on_child_class(self):
                self.method_on_base_class()
    
        instance = MyClass()
    
        assert not instance.method_on_base_class_was_called
        instance.method_on_child_class()
        assert instance.method_on_base_class_was_called
    
        output = string_io.getvalue()
>       assert_output(
            output,
            (
                SourcePathEntry(),
                VariableEntry('self', value_regex="u?.*MyClass object"),
                CallEntry('def method_on_child_class(self):'),
                LineEntry('self.method_on_base_class()'),
                ReturnEntry('self.method_on_base_class()'),
                ReturnValueEntry('None'),
                ElapsedTimeEntry(),
            ),
            normalize=normalize,
        )

tests/test_pysnooper.py:1778: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

output = 'Source path:... /builddir/build/BUILD/PySnooper-1.1.1/tests/test_pysnooper.py\nStarting var:.. self = <tests.test_pys...81347 line      1769             self.method_on_base_class()\nCall ended by exception\nElapsed time: 00:00:00.000136\n'
expected_entries = (SourcePathEntry(prefix=''), VariableEntry(name='self', prefix='', value_regex=re.compile('u?.*MyClass object')), Call...efix=''), ReturnEntry(source='self.method_on_base_class()', prefix=''), ReturnValueEntry(value='None', prefix=''), ...)
prefix = None, normalize = False

    def assert_output(output, expected_entries, prefix=None, normalize=False):
        lines = tuple(filter(None, output.split('\n')))
        if expected_entries and not lines:
            raise OutputFailure("Output is empty")
    
        if prefix is not None:
            for line in lines:
                if not line.startswith(prefix):
                    raise OutputFailure(line)
    
        if normalize:
            verify_normalize(lines, prefix)
    
        # Filter only entries compatible with the current Python
        filtered_expected_entries = []
        for expected_entry in expected_entries:
            if isinstance(expected_entry, _BaseEntry):
                if expected_entry.is_compatible_with_current_python_version():
                    filtered_expected_entries.append(expected_entry)
            else:
                filtered_expected_entries.append(expected_entry)
    
        expected_entries_count = len(filtered_expected_entries)
        any_mismatch = False
        result = ''
        template = u'\n{line!s:%s}   {expected_entry}  {arrow}' % max(map(len, lines))
        for expected_entry, line in zip_longest(filtered_expected_entries, lines, fillvalue=""):
            mismatch = not (expected_entry and expected_entry.check(line))
            any_mismatch |= mismatch
            arrow = '<===' * mismatch
            result += template.format(**locals())
    
        if len(lines) != expected_entries_count:
            result += '\nOutput has {} lines, while we expect {} lines.'.format(
                    len(lines), len(expected_entries))
    
        if any_mismatch:
>           raise OutputFailure(result)
E           tests.utils.OutputFailure: 
E           Source path:... /builddir/build/BUILD/PySnooper-1.1.1/tests/test_pysnooper.py                                                 SourcePathEntry(prefix='')  
E           Starting var:.. self = <tests.test_pysnooper.test_snooping_on_class_doe...nooped.<locals>.MyClass object at 0x7f30fd487380>   VariableEntry(name='self', prefix='', value_regex=re.compile('u?.*MyClass object'))  
E           17:40:43.381266 call      1768         def method_on_child_class(self):                                                       CallEntry(source='def method_on_child_class(self):', prefix='')  
E           17:40:43.381347 line      1769             self.method_on_base_class()                                                        LineEntry(source='self.method_on_base_class()', prefix='')  
E           Call ended by exception                                                                                                       ReturnEntry(source='self.method_on_base_class()', prefix='')  <===
E           Elapsed time: 00:00:00.000136                                                                                                 ReturnValueEntry(value='None', prefix='')  <===
E                                                                                                                                         ElapsedTimeEntry(tolerance=0.2, prefix='')  <===
E           Output has 6 lines, while we expect 7 lines.

tests/utils.py:399: OutputFailure
=============================== warnings summary ===============================
tests/test_pysnooper.py: 20 warnings
  /builddir/build/BUILD/PySnooper-1.1.1/pysnooper/tracer.py:470: DeprecationWarning: getName() is deprecated, get the name attribute instead
    ident=current_thread.ident, name=current_thread.getName())

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED tests/test_pysnooper.py::test_relative_time - tests.utils.OutputFailure: 
FAILED tests/test_pysnooper.py::test_watch[True] - tests.utils.OutputFailure: 
FAILED tests/test_pysnooper.py::test_watch[False] - tests.utils.OutputFailure: 
FAILED tests/test_pysnooper.py::test_watch_explode[True] - tests.utils.Output...
FAILED tests/test_pysnooper.py::test_watch_explode[False] - tests.utils.Outpu...
FAILED tests/test_pysnooper.py::test_variables_classes[True] - tests.utils.Ou...
FAILED tests/test_pysnooper.py::test_variables_classes[False] - tests.utils.O...
FAILED tests/test_pysnooper.py::test_single_watch_no_comma[True] - tests.util...
FAILED tests/test_pysnooper.py::test_single_watch_no_comma[False] - tests.uti...
FAILED tests/test_pysnooper.py::test_repr_exception[True] - tests.utils.Outpu...
FAILED tests/test_pysnooper.py::test_repr_exception[False] - tests.utils.Outp...
FAILED tests/test_pysnooper.py::test_with_block[True] - tests.utils.OutputFai...
FAILED tests/test_pysnooper.py::test_with_block[False] - tests.utils.OutputFa...
FAILED tests/test_pysnooper.py::test_var_order[True] - tests.utils.OutputFail...
FAILED tests/test_pysnooper.py::test_var_order[False] - tests.utils.OutputFai...
FAILED tests/test_pysnooper.py::test_indentation - AssertionError: assert 'So...
FAILED tests/test_pysnooper.py::test_generator - tests.utils.OutputFailure: 
FAILED tests/test_pysnooper.py::test_class[True] - tests.utils.OutputFailure: 
FAILED tests/test_pysnooper.py::test_class[False] - tests.utils.OutputFailure: 
FAILED tests/test_pysnooper.py::test_class_with_decorated_method[True] - test...
FAILED tests/test_pysnooper.py::test_class_with_decorated_method[False] - tes...
FAILED tests/test_pysnooper.py::test_class_with_decorated_method_and_snoop_applied_to_method[True]
FAILED tests/test_pysnooper.py::test_class_with_decorated_method_and_snoop_applied_to_method[False]
FAILED tests/test_pysnooper.py::test_class_with_property[True] - tests.utils....
FAILED tests/test_pysnooper.py::test_class_with_property[False] - tests.utils...
FAILED tests/test_pysnooper.py::test_snooping_on_class_does_not_cause_base_class_to_be_snooped[True]
FAILED tests/test_pysnooper.py::test_snooping_on_class_does_not_cause_base_class_to_be_snooped[False]
================== 27 failed, 51 passed, 20 warnings in 2.05s ==================

https://docs.python.org/3.12/whatsnew/3.12.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.12/fedora-rawhide-x86_64/05902813-python-pysnooper/

For all our attempts to build python-pysnooper with Python 3.12, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.12/package/python-pysnooper/

Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.12:
https://copr.fedorainfracloud.org/coprs/g/python/python3.12/

Let us know here if you have any questions.

Python 3.12 is planned to be included in Fedora 39. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.12.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon.
We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Zbigniew Jędrzejewski-Szmek 2023-05-12 19:22:17 UTC
https://github.com/cool-RR/PySnooper/issues/236

Comment 2 Fedora Update System 2023-07-16 10:48:23 UTC
FEDORA-2023-d55e21644e has been submitted as an update to Fedora 39. https://bodhi.fedoraproject.org/updates/FEDORA-2023-d55e21644e

Comment 3 Fedora Update System 2023-07-16 10:48:55 UTC
FEDORA-2023-d55e21644e has been pushed to the Fedora 39 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.