• Kirill Smelkov's avatar
    test/gen_testdata: Switch to random2 for PRNG · f38e7941
    Kirill Smelkov authored
    Python3 changed behaviour of random module compared to its previous
    behaviour under Python2:
    
        $ python2
        Python 2.7.18 (default, Jul 14 2021, 08:11:37)
        [GCC 10.2.1 20210110] on linux2
        Type "help", "copyright", "credits" or "license" for more information.
        >>> import random
        >>> random.seed(0)
        >>> for _ in range(5): print(random.randint(0,99))
        ...
        84
        75
        42
        25
        51
    
        $ python3
        Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
        Type "help", "copyright", "credits" or "license" for more information.
        >>> import random
        >>> random.seed(0)
        >>> for _ in range(5): print(random.randint(0,99))
        ...
        49
        97
        53
        5
        33
    
    Since gen_testdata.py uses PRNG heavily it means that with PRNG based on
    builtin random module of current python, generated output will differ
    strongly in between py2 and py3 versions.
    
    However we want generated outputs to be close to each other for py2 and
    py3 so that it is easier to analyze what is essential difference in
    generated databases.
    
    -> Make sure py2/py3 databases will be logically the same by explicitly
    using random2 and asserting that PRNG behaviour is stable independently
    of current python.
    
    No change in generated files as behaviour of random2 is by definition
    exactly the same as behaviour of builtin random on py2:
    
    https://pypi.org/project/random2/
    f38e7941
gen_testdata.py 11.5 KB