Skip to content

Commit

Permalink
Enhance test performance.
Browse files Browse the repository at this point in the history
Avoid parsing schema separately with each test.
  • Loading branch information
pekkaklarck committed Jun 9, 2023
1 parent a5a37e4 commit 41dcf39
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions utest/libdoc/test_libdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import unittest
from pathlib import Path

from jsonschema import validate
from jsonschema import Draft202012Validator

from robot.utils import PY_VERSION
from robot.utils.asserts import assert_equal
Expand All @@ -18,6 +18,9 @@
CURDIR = Path(__file__).resolve().parent
DATADIR = (CURDIR / '../../atest/testdata/libdoc/').resolve()
TEMPDIR = Path(os.getenv('TEMPDIR') or tempfile.gettempdir())
VALIDATOR = Draft202012Validator(
json.loads((CURDIR / '../../doc/schema/libdoc.json').read_text())
)

try:
from typing_extensions import TypedDict
Expand All @@ -41,9 +44,7 @@ def verify_keyword_shortdoc(doc_format, doc_input, expected):
def run_libdoc_and_validate_json(filename):
library = DATADIR / filename
json_spec = LibraryDocumentation(library).to_json()
with open(CURDIR / '../../doc/schema/libdoc.json') as file:
schema = json.load(file)
validate(instance=json.loads(json_spec), schema=schema)
VALIDATOR.validate(instance=json.loads(json_spec))


class TestHtmlToDoc(unittest.TestCase):
Expand Down

0 comments on commit 41dcf39

Please sign in to comment.