Fix code formatting - tox -e fmt
This commit is contained in:
@@ -8,7 +8,7 @@ import os
|
||||
import pytest
|
||||
|
||||
from openvixdisklib import nfc_open
|
||||
from tests.integration.base import LabEnv, SECTOR_SIZE, pattern_bytes
|
||||
from tests.integration.base import SECTOR_SIZE, LabEnv, pattern_bytes
|
||||
|
||||
_32MIB = 32 * 1024 * 1024
|
||||
|
||||
@@ -17,9 +17,9 @@ class TestNfcReadWrite:
|
||||
@pytest.mark.parametrize(
|
||||
"compression",
|
||||
[nfc_open.NFC_COMPRESSION_NONE, nfc_open.NFC_COMPRESSION_FASTLZ],
|
||||
ids=["plain", "fastlz"])
|
||||
def test_sector_writes_and_reads(
|
||||
self, lab: LabEnv, compression: int) -> None:
|
||||
ids=["plain", "fastlz"],
|
||||
)
|
||||
def test_sector_writes_and_reads(self, lab: LabEnv, compression: int) -> None:
|
||||
"""Write known patterns and read them back at several ranges."""
|
||||
ranges = [
|
||||
(0, 1),
|
||||
@@ -32,8 +32,8 @@ class TestNfcReadWrite:
|
||||
]
|
||||
with lab.authenticate(read_only=False) as session:
|
||||
with nfc_open.open_disk(
|
||||
session, lab.disk_path, read_only=False,
|
||||
compression=compression) as disk:
|
||||
session, lab.disk_path, read_only=False, compression=compression
|
||||
) as disk:
|
||||
for start, n_sectors in ranges:
|
||||
length = n_sectors * SECTOR_SIZE
|
||||
seed = f"NFC-R{start}:{n_sectors}-".encode()
|
||||
@@ -53,29 +53,29 @@ class TestNfcReadWrite:
|
||||
assert disk.read(1, 1) == two_to_write[SECTOR_SIZE:]
|
||||
|
||||
big_seed = b"NFC-129-SECTOR-WRITE"
|
||||
big_to_write = pattern_bytes(
|
||||
129 * SECTOR_SIZE, big_seed)
|
||||
big_to_write = pattern_bytes(129 * SECTOR_SIZE, big_seed)
|
||||
disk.write(0, 129, big_to_write)
|
||||
big_got = disk.read(0, 129)
|
||||
assert big_got is not big_to_write
|
||||
assert big_got == big_to_write
|
||||
assert (
|
||||
big_got[SECTOR_SIZE:2 * SECTOR_SIZE]
|
||||
== big_to_write[SECTOR_SIZE:2 * SECTOR_SIZE])
|
||||
big_got[SECTOR_SIZE : 2 * SECTOR_SIZE]
|
||||
== big_to_write[SECTOR_SIZE : 2 * SECTOR_SIZE]
|
||||
)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"compression",
|
||||
[nfc_open.NFC_COMPRESSION_NONE, nfc_open.NFC_COMPRESSION_FASTLZ],
|
||||
ids=["plain", "fastlz"])
|
||||
def test_write_and_read_32mb(
|
||||
self, lab: LabEnv, compression: int) -> None:
|
||||
ids=["plain", "fastlz"],
|
||||
)
|
||||
def test_write_and_read_32mb(self, lab: LabEnv, compression: int) -> None:
|
||||
"""Write 32 MiB (512 AIO chunks) and read it back in one request."""
|
||||
n_sectors = _32MIB // SECTOR_SIZE
|
||||
to_write = os.urandom(_32MIB)
|
||||
with lab.authenticate(read_only=False) as session:
|
||||
with nfc_open.open_disk(
|
||||
session, lab.disk_path, read_only=False,
|
||||
compression=compression) as disk:
|
||||
session, lab.disk_path, read_only=False, compression=compression
|
||||
) as disk:
|
||||
disk.write(0, n_sectors, to_write)
|
||||
got = disk.read(0, n_sectors)
|
||||
assert got is not to_write
|
||||
|
||||
Reference in New Issue
Block a user