nbdkit/0011-tests-python-Use-bytea...

43 lines
1.0 KiB
Diff

From 8b7a591c981df7db19334481cb43f95e9f5c420d Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 3 Oct 2016 14:14:25 +0100
Subject: [PATCH 11/11] tests: python: Use bytearray in the test.
Fixes the test on Python 3. Improves efficiency and memory usage of
the test on Python 2.
This makes the equivalent change to
commit 558dc7d84b46a1924e06808caa8b113238961fd3.
---
tests/test.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/test.py b/tests/test.py
index ffe0872..5d68b32 100644
--- a/tests/test.py
+++ b/tests/test.py
@@ -1,4 +1,4 @@
-disk = "\0" * (1024*1024);
+disk = bytearray (1024*1024);
def config_complete():
pass
@@ -24,12 +24,12 @@ def can_trim(h):
def pread(h, count, offset):
global disk
- return bytearray (disk[offset:offset+count])
+ return disk[offset:offset+count]
def pwrite(h, buf, offset):
global disk
end = offset + len (buf)
- disk = disk[:offset] + buf + disk[end:]
+ disk[offset:end] = buf
def flush(h):
pass
--
2.7.4