interegular icon indicating copy to clipboard operation
interegular copied to clipboard

[tests] test_slow_example fails sporadically

Open stanislavlevin opened this issue 1 year ago • 1 comments

interegular 0.3.2.

test_slow_example test randomly fails on different architectures. For example,

=================================== FAILURES =================================== 
_______________________ test_slow_example[SLOW_EXAMPLE] ________________________ 
                                                                                 
comp = <interegular.comparator.Comparator object at 0x7fffbc230550>              
expected = (('EXIT_TAG', 'COMMENT'),)                                            
                                                                                 
    @pytest.mark.parametrize("comp, expected", [                                 
        pytest.param(('EXIT_TAG', 'COMMENT'), (('EXIT_TAG', 'COMMENT'),), id="SLOW_EXAMPLE")
    ], indirect=['comp'])                                                        
    def test_slow_example(comp, expected):                                       
        for collision in expected:                                               
            start = perf_counter()                                               
            assert not comp.isdisjoint(*collision)                               
            try:                                                                 
                example = comp.get_example_overlap(*collision, 0.5)              
                assert comp.get_fsm(collision[0]).accepts(example)               
                assert comp.get_fsm(collision[1]).accepts(example)               
            except ValueError:                                                   
                pass                                                             
            end = perf_counter()                                                 
>           assert end - start < 1                                               
E           assert (1617056.717598456 - 1617055.271879278) < 1                   
                                                                                 
tests/test_comparator.py:62: AssertionError

Is this expected flaky test?

max_iterations = int((max_time - 0.09)/(1.4e-6 * len(alphabet)))

stanislavlevin avatar Jul 24 '23 14:07 stanislavlevin