From 5a830455cc12797551cdd90135d16ae7b80e5e29 Mon Sep 17 00:00:00 2001 From: Jakob Cornell Date: Fri, 12 Nov 2021 23:25:23 -0600 Subject: [PATCH] Cleanup --- src/disk_jumble/tests/test_verify.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/disk_jumble/tests/test_verify.py b/src/disk_jumble/tests/test_verify.py index facd67e..538f5fb 100644 --- a/src/disk_jumble/tests/test_verify.py +++ b/src/disk_jumble/tests/test_verify.py @@ -30,13 +30,12 @@ from disk_jumble.verify import do_verify _BUF_SIZE = 16 * 1024 ** 2 # in bytes -def _random_file(size: int) -> tempfile.NamedTemporaryFile: - r = Random(0) +def _random_file(size: int, rand_src: Random) -> tempfile.NamedTemporaryFile: f = tempfile.NamedTemporaryFile(buffering = _BUF_SIZE) try: while f.tell() < size: write_size = min(size - f.tell(), _BUF_SIZE) - f.write(bytes(r.getrandbits(8) for _ in range(write_size))) + f.write(bytes(rand_src.getrandbits(8) for _ in range(write_size))) f.seek(0) return f except Exception: @@ -46,7 +45,6 @@ def _random_file(size: int) -> tempfile.NamedTemporaryFile: class Tests(unittest.TestCase): _SCHEMAS = {"public", "diskjumble", "bittorrent"} - _BUF_SIZE = 16 * 1024 ** 2 # in bytes def _basic_fresh_verify_helper(self, read_size): sector_size = 32 @@ -54,7 +52,7 @@ class Tests(unittest.TestCase): torrent_len = 3 * piece_size disk = self._write_disk(sector_size, torrent_len // sector_size) - with _random_file(torrent_len) as torrent_file: + with _random_file(torrent_len, Random(0)) as torrent_file: torrent = _Torrent(torrent_file, piece_size) torrent_file.seek(0) self._write_torrent(torrent) -- 2.30.2