From 778c8318b49793e239ed616f1b982221a5c04160 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Sat, 12 Nov 2022 10:51:30 +0100 Subject: [PATCH 2/2] tests: improve determinism of some asserts (#70933) --- tests/test_application.py | 10 ++++++---- tox.ini | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/test_application.py b/tests/test_application.py index f85a624..4a6b955 100644 --- a/tests/test_application.py +++ b/tests/test_application.py @@ -306,8 +306,9 @@ def test_create_application(app, admin_user, settings, analyze): assert version.pk != same_version.pk resp = app.get('/applications/manifest/test/versions/') - assert resp.text.count('1.0') == 1 - assert resp.text.count('2.0') == 1 + versions = [e.text() for e in resp.pyquery('h3').items()] + assert versions.count('1.0') == 1 + assert versions.count('2.0') == 1 assert resp.text.count('Creating application bundle') == 3 resp = resp.click(href='/applications/manifest/test/download/%s/' % same_version.pk) assert resp.content_type == 'application/x-tar' @@ -327,8 +328,9 @@ def test_create_application(app, admin_user, settings, analyze): assert new_version.notes == 'Foo bar blah. But with an icon.' assert new_version.pk != version.pk # new version created resp = app.get('/applications/manifest/test/versions/') - assert resp.text.count('1.0') == 2 - assert resp.text.count('2.0') == 1 + versions = [e.text() for e in resp.pyquery('h3').items()] + assert versions.count('1.0') == 2 + assert versions.count('2.0') == 1 assert resp.text.count('Creating application bundle') == 4 # non editable app diff --git a/tox.ini b/tox.ini index f3061a3..5cf3b64 100644 --- a/tox.ini +++ b/tox.ini @@ -45,6 +45,7 @@ deps: coverage cssselect WebTest + pyquery django-mellon django-webtest Markdown<3 -- 2.37.2