Merge ~daniel-thewatkins/curtin/+git/curtin:tests into curtin:master

Proposed by Dan Watkins on 2019-10-23
Status: Merged
Approved by: Ryan Harper on 2019-10-23
Approved revision: 14a994fab9281d12561be52670b87e367d84fe54
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~daniel-thewatkins/curtin/+git/curtin:tests
Merge into: curtin:master
Diff against target: 13 lines (+1/-1)
1 file modified
tests/unittests/test_block_dasd.py (+1/-1)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve on 2019-10-23
Ryan Harper 2019-10-23 Approve on 2019-10-23
Review via email: mp+374624@code.launchpad.net

Commit message

test_block_dasd: fix random_device_id to only generate valid IDs

Previously we could generate an invalid one iff `random.randint(1,
0x10000)` returned 0x10000.

LP: #1849549

To post a comment you must log in.
Ryan Harper (raharper) wrote :

Thanks! We rolled that number far more often than I thought we would.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tests/unittests/test_block_dasd.py b/tests/unittests/test_block_dasd.py
2index 97ba77c..95788b0 100644
3--- a/tests/unittests/test_block_dasd.py
4+++ b/tests/unittests/test_block_dasd.py
5@@ -12,7 +12,7 @@ from .helpers import CiTestCase
6 def random_device_id():
7 return "%x.%x.%04x" % (random.randint(0, 255),
8 random.randint(0, 255),
9- random.randint(1, 0x10000))
10+ random.randint(1, 0x10000 - 1))
11
12
13 class TestDasdValidDeviceId(CiTestCase):

Subscribers

People subscribed via source and target branches