Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running frozen uuid.uuid4() several times change its value. #7

Open
alexismoreau opened this issue Sep 11, 2022 · 1 comment
Open

Comments

@alexismoreau
Copy link

Hello,
Running str(uuid.uuid4()) several times doesn't keep the value at 00000000-0000-0000-0000-000000000000.

str(uuid.uuid4())
str(uuid.uuid4())

gives as a result

00000000-0000-0000-0000-000000000000
00000000-0000-0000-0000-000000000001

That makes my tests fail :(

Reproduction :

def test_freeze_uuids(freeze_uuids):
    assert str(uuid.uuid4()) == "00000000-0000-0000-0000-000000000000"
    assert str(uuid.uuid4()) == "00000000-0000-0000-0000-000000000000"
@alexismoreau alexismoreau changed the title Running frozen uuid.uuid4() several times make it change its value. Running frozen uuid.uuid4() several times change its value. Sep 11, 2022
@Diapolo10
Copy link

I believe this is expected behaviour, because otherwise you'd run into issues immediately if the UUIDs were expected to retain their uniqueness - such as in databases.

It's still deterministic, meaning you can basically infer what values you'll be getting as long as you know the order of the UUID creation calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants