Skip to content

Commit

Permalink
Merge branch 'main' into fix_releaseherald_docs
Browse files Browse the repository at this point in the history
  • Loading branch information
zsambokiandras authored Feb 6, 2025
2 parents 5ebd267 + 4e10892 commit 9eee76f
Show file tree
Hide file tree
Showing 26 changed files with 371 additions and 110 deletions.
4 changes: 2 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
version: 2

build:
os: ubuntu-22.04
os: ubuntu-lts-latest
tools:
python: "3.7"
python: "3"
jobs:
post_checkout:
- git fetch --unshallow || true
Expand Down
9 changes: 7 additions & 2 deletions doc/en/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ def generate_news():


def setup(app):
app.add_stylesheet("icon.css")
app.add_stylesheet("news.css")
try:
app.add_css_file("icon.css")
app.add_css_file("news.css")
except AttributeError:
app.add_stylesheet("icon.css")
app.add_stylesheet("news.css")

generate_news()
17 changes: 12 additions & 5 deletions doc/en/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,27 @@ in your local environment!
Supported Python Versions
=========================

Testplan is tested to work with Python 3.7 and 3.8, 3.10 and 3.11 so we recommend choosing one of those.
Testplan is tested to work with Python 3.10 and 3.11 so we recommend choosing one of those. Python 3.7 and 3.8 support is deprecated and will be removed soon.

.. _install_testplan:

Install testplan
================

Testplan is not yet available from pypi.org but one can still install it from the latest github package. A link for our lates package can be obtained from: https://github.com/morganstanley/testplan/releases/tag/latest
Testplan is available from pypi.org: https://pypi.org/project/testplan/

.. code-block:: bash
python3 -m pip install testplan
Alternatively, one can install it from the latest github package. A link for our lates package can be obtained from: https://github.com/morganstanley/testplan/releases/tag/latest

Install from archive:

.. code-block:: bash
python3.7 -m pip install https://github.com/morganstanley/testplan/releases/download/latest/testplan-21.9.29-py3-none-any.whl
python3 -m pip install https://github.com/morganstanley/testplan/releases/download/24.9.2/testplan-24.9.2-py3-none-any.whl
Run testplan
Expand Down Expand Up @@ -76,8 +83,8 @@ Also find all our downloadable examples :ref:`here <download>`.

Working with the source
-----------------------

You will need a working python 3.7+ interrpreter preferably a venv, and for the interactive ui you need node installed.
You will need a working Python 3 interpreter preferably a venv, and for the interactive ui you need Node.js installed.
We are using `doit <https://pydoit.org/contents.html>`_ as the taskrunner ``doit list`` can show all the commands.

.. code-block:: text
Expand Down
5 changes: 5 additions & 0 deletions doc/en/index.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.. attention::

Support for Python 3.7 and 3.8 is deprecated and will be removed soon.
Please upgrade to newer versions.

.. raw:: html

<div style="font-size:80px;font-family:Arial;font-weight:bold;">
Expand Down
2 changes: 1 addition & 1 deletion doc/en/unittests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Python - unittest
=================

``unittest`` is the unit-testing framework built into the Python standard library,
see https://docs.python.org/3.7/library/unittest.html for more information.
see https://docs.python.org/3/library/unittest.html for more information.
``unittest`` testcases may be integrated with Testplan via the :py:class:`~testplan.testing.pyunit.PyUnit`
test runner. Example can be found :ref:`here <example_pyunit>`.

Expand Down
1 change: 1 addition & 0 deletions doc/newsfragments/3037_new.resource_monitor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a new summary page on resource view to show the task allocation per host.
1 change: 1 addition & 0 deletions doc/newsfragments/3055_deprecated.py37_38_deprecated.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support for Python 3.7 and 3.8 is deprecated and will be removed soon.
1 change: 1 addition & 0 deletions doc/newsfragments/3166_new.report_testplan_version.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Testplan now includes its own version in generated report.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove Sphinx and other packages for building document from Testplan's dependencies.
2 changes: 1 addition & 1 deletion examples/Multitest/Parallel/parallel_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self):
#
# Note that on Python 3 you can use the Barrier class from the standard
# library:
# https://docs.python.org/3.7/library/threading.html#barrier-objects .
# https://docs.python.org/3/library/threading.html#barrier-objects .
# Here we use a backported Barrier provided by Testplan, which works
# on both Python 2 and 3.
self._barrier = thread_utils.Barrier(2)
Expand Down
4 changes: 2 additions & 2 deletions examples/PyUnit/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TestAlpha(unittest.TestCase):
"""
Minimal PyUnit testcase with a single trivial test method. For more
information about the unittest library, see the [documentation](
http://docs.python.org/2/library/unittest.html).
http://docs.python.org/3/library/unittest.html).
"""

def test_example(self):
Expand All @@ -42,7 +42,7 @@ class TestBeta(unittest.TestCase):
"""
Minimal PyUnit testcase with a single trivial test method. For more
information about the unittest library, see the [documentation](
http://docs.python.org/2/library/unittest.html).
http://docs.python.org/3/library/unittest.html).
"""

def test_fails(self):
Expand Down
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
"Topic :: Software Development :: Testing :: Unit"
]
dependencies = [
"sphinx<2",
"sphinx_rtd_theme",
"setuptools",
"pytest",
"pytest-mock",
Expand Down Expand Up @@ -95,7 +93,7 @@
extend-exclude = "testplan/vendor"

[tool.bumpver]
current_version = "24.9.2"
current_version = "25.1.0"
version_pattern = "YY.MM.INC0"
commit_message = "bump version {old_version} -> {new_version}"
commit = true
Expand Down
5 changes: 5 additions & 0 deletions requirements-rtd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sphinx
sphinx-click
sphinx-rtd-theme
-r ./requirements.txt
./releaseherald
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ confluent-kafka
plotly
pandas
numpy
sphinx-click
doit
8 changes: 8 additions & 0 deletions testplan/exporters/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,12 @@ def __getattr__(name):
from .xml import XMLExporter

return XMLExporter
else:
import importlib

try:
return importlib.import_module("." + name, __name__)
except ModuleNotFoundError:
pass

raise AttributeError(f"module {__name__} has no attribute {name}")
14 changes: 11 additions & 3 deletions testplan/testing/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ def _create_case_or_override(
return case_report

def _run_resource_hook(
self, hook: Callable, hook_name: str, suite_name: str
self, hook: Optional[Callable], hook_name: str, suite_name: str
) -> None:
# TODO: env or env, result signature is mandatory not an "if"
"""
Expand Down Expand Up @@ -698,7 +698,11 @@ def _run_resource_hook(
interface.check_signature(hook, ["env"])
hook_args = (runtime_env,)
with compose_contexts(*self._get_hook_context(case_report)):
hook(*hook_args)
try:
res = hook(*hook_args)
except Exception as e:
res = e
raise

case_report.extend(case_result.serialized_entries)
case_report.attachments.extend(case_result.attachments)
Expand All @@ -710,8 +714,12 @@ def _run_resource_hook(
self._xfail(pattern, case_report)
case_report.runtime_status = RuntimeStatus.FINISHED

if isinstance(res, Exception):
raise res
return res

def _dry_run_resource_hook(
self, hook: Callable, hook_name: str, suite_name: str
self, hook: Optional[Callable], hook_name: str, suite_name: str
) -> None:
if not hook:
return
Expand Down
2 changes: 1 addition & 1 deletion testplan/testing/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ class Pattern(Filter):
"""
Base class for name based, glob style filtering.
https://docs.python.org/3.4/library/fnmatch.html
https://docs.python.org/3/library/fnmatch.html
Examples:
Expand Down
25 changes: 11 additions & 14 deletions testplan/testing/multitest/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,6 @@ def get_options(cls):
and tup[1] > 1,
),
),
config.ConfigOption("multi_part_uid", default=None): Or(
None, lambda x: callable(x)
),
config.ConfigOption("fix_spec_path", default=None): Or(
None, And(str, os.path.exists)
),
Expand Down Expand Up @@ -261,9 +258,6 @@ class MultiTest(testing_base.Test):
:param part: Execute only a part of the total testcases. MultiTest needs to
know which part of the total it is. Only works with Multitest.
:type part: ``tuple`` of (``int``, ``int``)
:param multi_part_uid: Custom function to overwrite the uid of test entity
if `part` attribute is defined, otherwise use default implementation.
:type multi_part_uid: ``callable``
:type result: :py:class:`~testplan.testing.multitest.result.result.Result`
:param fix_spec_path: Path of fix specification file.
:type fix_spec_path: ``NoneType`` or ``str``.
Expand Down Expand Up @@ -296,7 +290,6 @@ def __init__(
thread_pool_size=0,
max_thread_pool_size=10,
part=None,
multi_part_uid=None,
before_start=None,
after_start=None,
before_stop=None,
Expand All @@ -310,6 +303,14 @@ def __init__(
):
self._tags_index = None

if "multi_part_uid" in options:
# might be replaced by multi_part_name_func
warnings.warn(
"MultiTest uid can no longer be customised, please remove ``multi_part_uid`` argument.",
DeprecationWarning,
)
del options["multi_part_uid"]

options.update(self.filter_locals(locals()))
super(MultiTest, self).__init__(**options)

Expand Down Expand Up @@ -345,12 +346,8 @@ def uid(self):
A Multitest part instance should not have the same uid as its name.
"""
if self.cfg.part:
return (
self.cfg.multi_part_uid(self.cfg.name, self.cfg.part)
if self.cfg.multi_part_uid
else TEST_PART_PATTERN_FORMAT_STRING.format(
self.cfg.name, self.cfg.part[0], self.cfg.part[1]
)
return TEST_PART_PATTERN_FORMAT_STRING.format(
self.cfg.name, self.cfg.part[0], self.cfg.part[1]
)
else:
return self.cfg.name
Expand Down Expand Up @@ -529,7 +526,7 @@ def run_testcases_iter(
self,
testsuite_pattern: str = "*",
testcase_pattern: str = "*",
shallow_report: Dict = None,
shallow_report: Optional[Dict] = None,
) -> Generator:
"""
Run all testcases and yield testcase reports.
Expand Down
10 changes: 5 additions & 5 deletions testplan/testing/py_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from testplan.testing.multitest.entries.stdout.base import (
registry as stdout_registry,
)
from testplan.testing.result import Result as MultiTestResult
from testplan.testing.result import Result

# Regex for parsing suite and case name and case parameters
_CASE_REGEX = re.compile(
Expand All @@ -49,9 +49,9 @@ def get_options(cls):
"target": Or(str, [str]),
ConfigOption("select", default=""): str,
ConfigOption("extra_args", default=None): Or([str], None),
ConfigOption(
"result", default=MultiTestResult
): validation.is_subclass(MultiTestResult),
ConfigOption("result", default=Result): validation.is_subclass(
Result
),
}


Expand Down Expand Up @@ -85,7 +85,7 @@ def __init__(
description=None,
select="",
extra_args=None,
result=MultiTestResult,
result=Result,
**options
):
options.update(self.filter_locals(locals()))
Expand Down
2 changes: 1 addition & 1 deletion testplan/version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import time

__version__ = "24.9.2"
__version__ = "25.1.0"

dev_build = int(os.environ.get("DEV_BUILD", "0"))
dev_suffix = f"dev{int(time.time())}" if dev_build else ""
Expand Down
Loading

0 comments on commit 9eee76f

Please sign in to comment.