Skip to content

Commit 9e40767

Browse files
committed
gh-139122: Narrow UUID exception assertions and clean up test spacing
1 parent 8ebad36 commit 9e40767

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎Lib/test/test_uuid.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,9 @@ def __getitem__(self, key):
533533
for bad_key in ('int', 'is_safe'):
534534
with self.subTest(key=bad_key):
535535
u = self.uuid.UUID(int=1)
536+
state = State(int=2, is_safe=0)
536537
with self.assertRaisesRegex(RuntimeError, 'lookup failed'):
537-
u.__setstate__(State(int=2, is_safe=0))
538+
u.__setstate__(state)
538539

539540
def test_setstate_contains_error(self):
540541
class State(dict):
@@ -543,8 +544,9 @@ def __contains__(self, key):
543544

544545
# Errors checking for the optional key must propagate as well.
545546
u = self.uuid.UUID(int=1)
547+
state = State(int=2)
546548
with self.assertRaisesRegex(RuntimeError, 'membership test failed'):
547-
u.__setstate__(State(int=2))
549+
u.__setstate__(state)
548550

549551
def test_setstate_invalid_is_safe(self):
550552
u = self.uuid.UUID(int=0)
@@ -1748,9 +1750,9 @@ def __init__(self, *, start_at=0, inc_by=0, seed=0):
17481750
self._inc_by = inc_by
17491751
self._rnd = random.Random(seed)
17501752

1751-
def random_func (self, size) :
1753+
def random_func(self, size):
17521754
ret = b''
1753-
for _ in range(size) :
1755+
for _ in range(size):
17541756
ret += self._rnd.getrandbits(8).to_bytes(1, 'big')
17551757
return ret
17561758

0 commit comments

Comments
 (0)