Skip to content

test_write_if_different is prone to race conditions #43

Description

@mweinelt

Hi, we're seeing the following error on our build hosts with extension-helpers 1.0.0.

    def test_write_if_different(tmpdir):
        filename = str(tmpdir / 'test.txt')
        write_if_different(filename, b'abc')
        time1 = os.path.getmtime(filename)
        time.sleep(0.01)
        write_if_different(filename, b'abc')
        time2 = os.path.getmtime(filename)
        assert time2 == time1
        time.sleep(0.01)
        write_if_different(filename, b'abcd')
        time3 = os.path.getmtime(filename)
>       assert time3 > time1
E       assert 1650038922.0 > 1650038922.0

The mtime resolution depends on the filesystem implementation, so ideally you would choose a higher timeout.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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