• Kirill Smelkov's avatar
    analyze: test: Fix tidmin thinko in "empty range" test · 65ebbe7b
    Kirill Smelkov authored
    Empty-range test added in b4824ad5 (analyze: fix ZeroDivisionErrors when
    report is empty) intended to use 0xffffffffffffffff TID, but used just
    'ffffffffffffffff' string instead. It was passing on py2 partly by luck,
    but on py3 it fails because tidmin type is mismatched:
    
        _______________________________ test_zodbanalyze _______________________________
    
        tmpdir = local('/tmp/pytest-of-kirr/pytest-30/test_zodbanalyze0')
        capsys = <_pytest.capture.CaptureFixture object at 0x7f7bb3f9a4f0>
    
            def test_zodbanalyze(tmpdir, capsys):
                ...
    
                # empty range
                report(
        >           analyze(
                        tfs1,
                        use_dbm=False,
                        delta_fs=False,
                        tidmin="ffffffffffffffff",
                        tidmax=None,
                    ),
                    csv=False,
                )
    
        zodbtools/test/test_analyze.py:68:
        _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
        ../../venv/py3.venv/lib/python3.9/site-packages/decorator.py:232: in fun
            return caller(func, *(extras + args), **kw)
        ../../../tools/go/pygolang/golang/__init__.py:103: in _
            return f(*argv, **kw)
        zodbtools/zodbanalyze.py:181: in analyze
            fsi = fs.iterator(tidmin, tidmax)
        ../ZODB/src/ZODB/FileStorage/FileStorage.py:1381: in iterator
            return FileIterator(self._file_name, start, stop)
        _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    
        self = <ZODB.FileStorage.FileStorage.FileIterator object at 0x7f7bb348c6d0>
        filename = '/tmp/pytest-of-kirr/pytest-30/test_zodbanalyze0/1.fs'
        start = 'ffffffffffffffff', stop = None, pos = 4
    
            def __init__(self, filename, start=None, stop=None, pos=4):
                assert isinstance(filename, STRING_TYPES)
                file = open(filename, 'rb')
                self._file = file
                self._file_name = filename
                if file.read(4) != packed_version:
                    raise FileStorageFormatError(file.name)
                file.seek(0, 2)
                self._file_size = file.tell()
                if (pos < 4) or pos > self._file_size:
                    raise ValueError("Given position is greater than the file size",
                                     pos, self._file_size)
                self._pos = pos
        >       assert start is None or isinstance(start, bytes)
        E       AssertionError
    
        ../ZODB/src/ZODB/FileStorage/FileStorage.py:1816: AssertionError
        ------------------------------ Captured log call -------------------------------
        ERROR    ZODB.FileStorage:FileStorage.py:480 loading index
        UnicodeDecodeError: 'ascii' codec can't decode byte 0xb7 in position 25: ordinal not in range(128)
    
        The above exception was the direct cause of the following exception:
    
        Traceback (most recent call last):
          File "/home/kirr/src/wendelin/z/ZODB/src/ZODB/FileStorage/FileStorage.py", line 478, in _restore_index
            info = fsIndex.load(index_name)
          File "/home/kirr/src/wendelin/z/ZODB/src/ZODB/fsIndex.py", line 138, in load
            v = unpickler.load()
        SystemError: <built-in method read of _io.BufferedReader object at 0x7f7bb3df03b0> returned a result with an error set
        ERROR    ZODB.FileStorage:FileStorage.py:480 loading index
        UnicodeDecodeError: 'ascii' codec can't decode byte 0xb7 in position 25: ordinal not in range(128)
    
        ...
    
    -> Fix it by preparing tidmin in the test a 8-bytes binary properly.
    65ebbe7b
test_analyze.py 2.47 KB