diff --git a/pyproject.toml b/pyproject.toml index 90309e991..f9200476f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,6 @@ "pandas", # required by plotly.express "rpyc", "matplotlib", - "memoization", "coverage", "typing_extensions", "dill", diff --git a/testplan/common/utils/path.py b/testplan/common/utils/path.py index d60a42e9d..64cd6e764 100644 --- a/testplan/common/utils/path.py +++ b/testplan/common/utils/path.py @@ -8,16 +8,16 @@ import contextlib import tempfile import hashlib +from functools import lru_cache from io import TextIOWrapper from testplan.common.utils.context import render -from memoization import cached from .strings import slugify VAR_TMP = os.path.join(os.sep, "var", "tmp") -@cached +@lru_cache(None) def fix_home_prefix(path): """ Try to replace a real path (/a/path/user) with a symlink diff --git a/testplan/report/testing/schemas.py b/testplan/report/testing/schemas.py index 134456ebc..9b4b991e1 100644 --- a/testplan/report/testing/schemas.py +++ b/testplan/report/testing/schemas.py @@ -153,7 +153,7 @@ class Meta: meta = fields.Dict() label = fields.String(allow_none=True) tags_index = TagField(dump_only=True) - information = fields.List(fields.List(fields.String())) + information = fields.List(fields.Tuple([fields.String(), fields.String()])) resource_meta_path = fields.String(dump_only=True, allow_none=True) counter = fields.Dict(dump_only=True) diff --git a/testplan/runnable/base.py b/testplan/runnable/base.py index 8e533718a..c427114e2 100644 --- a/testplan/runnable/base.py +++ b/testplan/runnable/base.py @@ -418,6 +418,7 @@ def __init__(self, **options): uid=self.cfg.name, timeout=self.cfg.timeout, label=self.cfg.label, + information=[("testplan_version", self.get_testplan_version())], ) self._exporters = None self._web_server_thread = None @@ -440,6 +441,12 @@ def __init__(self, **options): def __str__(self): return f"Testplan[{self.uid()}]" + @staticmethod + def get_testplan_version(): + import testplan + + return testplan.__version__ + @property def report(self) -> TestReport: """Tests report.""" diff --git a/testplan/testing/base.py b/testplan/testing/base.py index 3c2e349b5..611552b07 100644 --- a/testplan/testing/base.py +++ b/testplan/testing/base.py @@ -1,37 +1,39 @@ """Base classes for all Tests""" import functools import os -import re import subprocess import sys import warnings from enum import Enum -from schema import And, Or, Use from typing import ( + Callable, Dict, Generator, + Iterable, List, Optional, - Union, - Callable, - Iterable, - Type, Tuple, + Type, + Union, ) + import plotly.express as px +from schema import And, Or, Use from testplan import defaults from testplan.common.config import ConfigOption, validate_func from testplan.common.entity import ( Resource, ResourceStatus, + ResourceTimings, Runnable, RunnableConfig, RunnableResult, - ResourceTimings, ) from testplan.common.remote.remote_driver import RemoteDriver -from testplan.common.utils import strings, interface, validation +from testplan.common.report import ReportCategories, RuntimeStatus +from testplan.common.report import Status as ReportStatus +from testplan.common.utils import interface, strings, validation from testplan.common.utils.composer import compose_contexts from testplan.common.utils.context import render from testplan.common.utils.process import ( @@ -40,24 +42,13 @@ subprocess_popen, ) from testplan.common.utils.timing import format_duration, parse_duration -from testplan.common.report import ( - Status as ReportStatus, - ReportCategories, - RuntimeStatus, -) -from testplan.report import ( - TestCaseReport, - TestGroupReport, - test_styles, -) -from testplan.testing import common, filtering, ordering, tagging, result +from testplan.report import TestCaseReport, TestGroupReport, test_styles +from testplan.testing import common, filtering, ordering, result, tagging from testplan.testing.environment import TestEnvironment, parse_dependency +from testplan.testing.multitest.driver.connection import DriverConnectionGraph from testplan.testing.multitest.entries.assertions import RawAssertion from testplan.testing.multitest.entries.base import Attachment from testplan.testing.multitest.test_metadata import TestMetadata -from testplan.testing.multitest.driver.connection import DriverConnectionGraph - -from testplan.testing.multitest import result TEST_INST_INDENT = 2 SUITE_INDENT = 4 diff --git a/tests/functional/testplan/exporters/testing/test_json.py b/tests/functional/testplan/exporters/testing/test_json.py index f722fe9e2..abe89df06 100644 --- a/tests/functional/testplan/exporters/testing/test_json.py +++ b/tests/functional/testplan/exporters/testing/test_json.py @@ -6,6 +6,7 @@ import pathlib import tempfile +import testplan from testplan import TestplanMock from testplan.common.utils.testing import argv_overridden from testplan.exporters.testing import JSONExporter @@ -83,6 +84,9 @@ def test_split_and_merge(runpath): copy.deepcopy(report) ) assert "information" in meta + assert ( + dict(meta["information"])["testplan_version"] == testplan.__version__ + ) assert meta["entries"] == [] assert ( JSONExporter.merge_json_report(meta, structure, assertions) == report diff --git a/tests/unit/testplan/runnable/interactive/test_api.py b/tests/unit/testplan/runnable/interactive/test_api.py index 9b1bba0ce..41c76bbe1 100644 --- a/tests/unit/testplan/runnable/interactive/test_api.py +++ b/tests/unit/testplan/runnable/interactive/test_api.py @@ -206,6 +206,9 @@ def test_put_filtered(self, api_env): json_report[ "runtime_status" ] = report.RuntimeStatus.RUNNING.to_json_compatible() + json_report["information"] = [ + list(t) for t in json_report["information"] + ] rsp = client.put("/api/v1/interactive/report", json=json_report) assert rsp.status_code == 200