# -*- coding: utf-8 -*- """Test-vector loading helper. Mirrors the loader used by the sibling ``purepycrypto`` project so the two repositories share the same layout convention: a ``vectors/`` directory next to the tests, one JSON file per subject, loaded by name. """ import json import os VEC_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "vectors") def path_for(name): """Absolute path of ``vectors/.json``.""" return os.path.join(VEC_DIR, name + ".json") def load(name): """Load ``vectors/.json`` and return the parsed dictionary.""" with open(path_for(name), "r", encoding="utf-8") as f: return json.load(f) def available(): """Names of every vector file present, without the ``.json`` suffix.""" if not os.path.isdir(VEC_DIR): return [] return sorted( f[:-5] for f in os.listdir(VEC_DIR) if f.endswith(".json") )