diff --git a/spinnaker_testbase/base_test_case.py b/spinnaker_testbase/base_test_case.py index d587cc0..6d626e5 100644 --- a/spinnaker_testbase/base_test_case.py +++ b/spinnaker_testbase/base_test_case.py @@ -62,8 +62,6 @@ def assert_logs_messages( def get_system_iobuf_files(self) -> List[str]: """ Get a list of the system iobuf files. - - :rtype: list(str) """ system_iobuf_file_path = FecDataView.get_system_provenance_dir_path() return os.listdir(system_iobuf_file_path) @@ -71,8 +69,6 @@ def get_system_iobuf_files(self) -> List[str]: def get_app_iobuf_files(self) -> List[str]: """ Get a list of the application iobuf files. - - :rtype: list(str) """ app_iobuf_file_path = FecDataView.get_app_provenance_dir_path() return os.listdir(app_iobuf_file_path) diff --git a/spinnaker_testbase/ping.py b/spinnaker_testbase/ping.py index fb26e87..3136e9c 100644 --- a/spinnaker_testbase/ping.py +++ b/spinnaker_testbase/ping.py @@ -32,12 +32,11 @@ def ping(ip_address: str) -> int: Send a ping (ICMP ECHO request) to the given host. SpiNNaker boards support ICMP ECHO when booted. - :param str ip_address: + :param ip_address: The IP address to ping. Hostnames can be used, but are not recommended. :return: return code of subprocess; 0 for success, anything else for failure - :rtype: int """ if platform.platform().lower().startswith("windows"): cmd = "ping -n 1 -w 1 " @@ -61,10 +60,9 @@ def host_is_reachable(ip_address: str) -> bool: This information may be cached in various ways. Transient failures are not necessarily detected or recovered from. - :param str ip_address: + :param ip_address: The IP address to ping. Hostnames can be used, but are not recommended. - :rtype: bool """ if ip_address in Ping.unreachable: return False diff --git a/spinnaker_testbase/root_script_builder.py b/spinnaker_testbase/root_script_builder.py index e5b382b..f80980a 100644 --- a/spinnaker_testbase/root_script_builder.py +++ b/spinnaker_testbase/root_script_builder.py @@ -33,10 +33,10 @@ class RootScriptBuilder(object): def add_script(self, test_file: TextIOBase, name: str, local_path: str, skip_imports: Optional[List[str]]) -> None: """ - :param io.TextIOBase test_file: - :param str name: - :param str local_path: - :param list(str) skip_imports: + :param test_file: + :param name: + :param local_path: + :param skip_imports: """ test_file.write("\n def test_") test_file.write(name) @@ -62,12 +62,12 @@ def add_scripts(self, a_dir: str, prefix_len: int, test_file: TextIOBase, too_long: Dict[str, str], exceptions: Dict[str, str], skip_exceptions: Dict[str, List[str]]) -> None: """ - :param str a_dir: - :param int prefix_len: - :param io.TextIOBase test_file: - :param dict(str,str) too_long: - :param dict(str,str) exceptions: - :param dict(str,list(str)) skip_exceptions: + :param a_dir: + :param prefix_len: + :param test_file: + :param too_long: + :param exceptions: + :param skip_exceptions: """ for a_script in os.listdir(a_dir): script_path = os.path.join(a_dir, a_script) @@ -108,18 +108,15 @@ def create_test_scripts( """ :param dirs: List of dirs to find scripts in. These are relative paths to the repository - :type dirs: str or list(str) :param too_long: Dict of files that take too long to run and how long. These are just the file name including the `.py`. They are mapped to a skip reason. These are only skip tests if asked to be (currently not done). - :type too_long: dict(str, str) or None :param exceptions: Dict of files that should be skipped. These are just the file name including the `.py`. They are mapped to a skip reason. These are always skipped. - :type exceptions: dict(str, str) or None - :param dict(str,list(str)) skip_exceptions: + :param skip_exceptions: Dict of files and exceptions to skip on. These are just the file name including the `.py`. They are mapped to a list of INDIVIUAL import statements diff --git a/spinnaker_testbase/root_test_case.py b/spinnaker_testbase/root_test_case.py index 0573ecf..8c7111f 100644 --- a/spinnaker_testbase/root_test_case.py +++ b/spinnaker_testbase/root_test_case.py @@ -76,8 +76,8 @@ def report(self, message: str, file_name: str) -> None: If no GLOBAL_REPORTS is defined the timestamp directory holding the run data is used. - :param str message: - :param str file_name: local file name. + :param message: + :param file_name: local file name. """ if not message.endswith("\n"): message += "\n" @@ -104,11 +104,10 @@ def runsafe(self, method: Callable, retry_delay: float = 3.0, """ Will run the method possibly a few times - :param callable method: - :param float retry_delay: + :param method: + :param retry_delay: :param skip_exceptions: list of exception classes to convert in SkipTest - :type skip_exceptions: list(class) """ if skip_exceptions is None: skip_exceptions = [] diff --git a/spinnaker_testbase/script_checker.py b/spinnaker_testbase/script_checker.py index 532b4f6..30db1e6 100644 --- a/spinnaker_testbase/script_checker.py +++ b/spinnaker_testbase/script_checker.py @@ -57,13 +57,12 @@ def _script_path(self, script: str) -> str: def check_script(self, script: str, broken_msg: Optional[str] = None, skip_exceptions: Optional[List[type]] = None) -> None: """ - :param str script: relative path to the file to run - :param str broken_msg: + :param script: relative path to the file to run + :param broken_msg: message to print instead of raising an exception; no current use-case known :param skip_exceptions: list of exception classes to convert in SkipTest - :type skip_exceptions: list(type) or None """ # pylint: disable=global-statement global script_checker_shown diff --git a/unittests/test_doc_checker.py b/unittests/test_doc_checker.py new file mode 100644 index 0000000..079cad8 --- /dev/null +++ b/unittests/test_doc_checker.py @@ -0,0 +1,37 @@ +# Copyright (c) 2017 The University of Manchester +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import sys +import unittest + +from spinn_utilities.config_setup import unittest_setup +from spinn_utilities.testing.docs_checker import DocsChecker + + +class TestCfgChecker(unittest.TestCase): + + def setUp(self) -> None: + unittest_setup() + + def test_doc_checks(self) -> None: + class_file = sys.modules[self.__module__].__file__ + assert class_file is not None + abs_class_file = os.path.abspath(class_file) + unittest_dir = os.path.dirname(abs_class_file) + repo_dir = os.path.dirname(unittest_dir) + checker = DocsChecker( + check_init=False, check_short=False, check_params=False) + checker.check_dir(repo_dir) + checker.check_no_errors()