tests: use pytest instead of unittest

pytest provides session scoped fixtures, making it much easier
to reuse resources across tests.
This commit is contained in:
Lucian Petrut
2026-09-07 11:52:46 +00:00
parent 4ddf0c015d
commit 1e9c2816ef
15 changed files with 403 additions and 454 deletions
+11 -11
View File
@@ -4,20 +4,20 @@
"""Exercise NFC disk open and a one-sector write/read against the lab."""
from openvixdisklib import nfc_open
from tests.integration.base import TestBase
from tests.integration.base import LabEnv, SECTOR_SIZE, pattern_bytes
class NfcOpenTest(TestBase):
def test_open_disk_and_read_first_sector(self) -> None:
class TestNfcOpen:
def test_open_disk_and_read_first_sector(self, lab: LabEnv) -> None:
"""Open the temp VMDK, write sector 0, and read it back."""
expected = self.pattern_bytes(self.SECTOR_SIZE, b"NFC-OPEN-S0")
with self.authenticate(read_only=False) as session:
expected = pattern_bytes(SECTOR_SIZE, b"NFC-OPEN-S0")
with lab.authenticate(read_only=False) as session:
with nfc_open.open_disk(
session, self.DISK_PATH, read_only=False) as disk:
self.assertEqual(disk.path, self.DISK_PATH)
self.assertGreater(disk.handle, 0)
self.assertEqual(disk.sector_size, self.SECTOR_SIZE)
session, lab.disk_path, read_only=False) as disk:
assert disk.path == lab.disk_path
assert disk.handle > 0
assert disk.sector_size == SECTOR_SIZE
disk.write(0, 1, expected)
got = disk.read(0, 1)
self.assertIsNot(got, expected)
self.assertEqual(got, expected)
assert got is not expected
assert got == expected