Skip to content

Flaky test: test_tracked_slugs #4924

@greg-hellings

Description

@greg-hellings

When running the test suite, I get intermittent failures from the test_tracked_slugs test. Running the suite back to back in the same environment I got one failure and one success. Failure as follows:

python3.12-textual> =================================== FAILURES ===================================                                                                                                                                          
python3.12-textual> ______________________ test_tracked_slugs[ test -test-5] _______________________                                                                                                                                          
python3.12-textual> [gw13] linux -- Python 3.12.4 /nix/store/l014xp1qxdl6gim3zc0jv3mpxhbp346s-python3-3.12.4/bin/python3.12                                                                                                                   
python3.12-textual> tracker = <textual._slug.TrackedSlugs object at 0x7fffee7e4e30>, text = ' test '                                                                                                                                          
python3.12-textual> expected = 'test-5'                                                                                                                                                                                                       
python3.12-textual>     @pytest.mark.xdist_group("group2")                                                                                                                                                                                    
python3.12-textual>     @pytest.mark.parametrize(                                                                                                                                                                                             
python3.12-textual>         "text, expected",                                                                                                                                                                                                 
python3.12-textual>         [                                                                                                                                                                                                                 
python3.12-textual>             ("test", "test"),                                                                                                                                                                                             
python3.12-textual>             ("test", "test-1"),                                                                                                                                                                                           
python3.12-textual>             ("test", "test-2"),                                                                                                                                                                                           
python3.12-textual>             ("-test-", "-test-"),                                                                                                                                                                                         
python3.12-textual>             ("-test-", "-test--1"),                                                                                                                                                                                       
python3.12-textual>             ("test!\"#$%&'()*+,-./:;<=>?@[]^_`{|}~test", "test-_test"),                                                                                                                                                   
python3.12-textual>             ("test!\"#$%&'()*+,-./:;<=>?@[]^_`{|}~test", "test-_test-1"),                                                                                                                                                 
python3.12-textual>             ("tëst", "t%C3%ABst"),                                                                                                                                                                                        
python3.12-textual>             ("tëst", "t%C3%ABst-1"),                                                                                                                                                                                      
python3.12-textual>             ("tëst", "t%C3%ABst-2"),                                                                                                                                                                                      
python3.12-textual>             ("test🙂test", "testtest"),                                                                                                                                                                                   
python3.12-textual>             ("test🤷test", "testtest-1"),                                                                                                                                                                                 
python3.12-textual>             ("test🤷🏻‍♀️test", "testtest-2"),                                                                                                                                                                              python3.12-textual>             ("test", "test-3"),                                                                                                                                                                                           
python3.12-textual>             ("test", "test-4"),                                                                                                                                                                                           
python3.12-textual>             (" test ", "test-5"),                                                                                                                                                                                         
python3.12-textual>         ],                                                                                                                                                                                                                
python3.12-textual>     )                                                                                                                                                                                                                     
python3.12-textual>     def test_tracked_slugs(tracker: TrackedSlugs, text: str, expected: str) -> None:                                                                                                                                      
python3.12-textual>         """The tracked slugging class should produce the expected slugs."""                                                                                                                                               
python3.12-textual> >       assert tracker.slug(text) == expected                                                                                                                                                                             
python3.12-textual> E       AssertionError: assert 'test' == 'test-5'                                                                                                                                                                         
python3.12-textual> E                                                                                                                                                                                                                         
python3.12-textual> E         - test-5                                                                                                                                                                                                        
python3.12-textual> E         ?     --                                                                                                                                                                                                        
python3.12-textual> E         + test
python3.12-textual> tests/test_slug.py:64: AssertionError
python3.12-textual> =========================== short test summary info ============================
python3.12-textual> FAILED tests/test_slug.py::test_tracked_slugs[ test -test-5] - AssertionError: assert 'test' == 'test-5'
python3.12-textual> ============ 1 failed, 2572 passed, 1 skipped, 3 xfailed in 13.93s =============
python3.12-textual> /nix/store/1r32fki5z5ivgaikgh8pq0r6vz3b0jpj-stdenv-linux/setup: line 1655: pop_var_context: head of shell_variables not a function context
error: builder for '/nix/store/89vr75dzk1mlpvmmmj2krpr6iafycc7x-python3.12-textual-0.76.0.drv' failed with exit code 1;
       last 10 log lines:
       > E         
       > E         - test-5
       > E         ?     --
       > E         + test
       >
       > tests/test_slug.py:64: AssertionError
       > =========================== short test summary info ============================
       > FAILED tests/test_slug.py::test_tracked_slugs[ test -test-5] - AssertionError: assert 'test' == 'test-5'
       > ============ 1 failed, 2572 passed, 1 skipped, 3 xfailed in 13.93s =============
       > /nix/store/1r32fki5z5ivgaikgh8pq0r6vz3b0jpj-stdenv-linux/setup: line 1655: pop_var_context: head of shell_variables not a function context
       For full logs, run 'nix log /nix/store/89vr75dzk1mlpvmmmj2krpr6iafycc7x-python3.12-textual-0.76.0.drv'.

Running the test suite again, immediately afterwards, resulted in a success. I can only assume there is some sort of race condition or non-deterministic behavior in ordering of the tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions