Skip to content

Commit

Permalink
Add global random seed for deterministic tests (#138)
Browse files Browse the repository at this point in the history
* update test_basic.py to add seed

* refactor: use random as an attribute in TestFramework
  • Loading branch information
allrob23 authored Mar 3, 2025
1 parent e6896e1 commit 3b25cd5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 1 addition & 2 deletions amqpstorm/tests/unit/basic/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
import random
import string
import sys

Expand Down Expand Up @@ -238,7 +237,7 @@ def test_basic_create_content_body(self):

def test_basic_create_content_body_growing(self):
basic = Basic(None)
long_string = ''.join(random.choice(string.ascii_letters)
long_string = ''.join(self.random.choice(string.ascii_letters)
for _ in RANGE(32768))

for index in RANGE(32768):
Expand Down
2 changes: 2 additions & 0 deletions amqpstorm/tests/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from amqpstorm.connection import Channel
from amqpstorm.connection import Connection
import random

try:
import unittest2 as unittest
Expand Down Expand Up @@ -173,6 +174,7 @@ class TestFramework(unittest.TestCase):
message = str(uuid.uuid4())

def __init__(self, *args, **kwargs):
self.random = random.Random(42)
self.channel = None
self.connection = None
self.validate_logging = True
Expand Down

0 comments on commit 3b25cd5

Please sign in to comment.