From 96feb15a630a954228216c11354804b3be408aa9 Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Fri, 23 Jun 2023 16:52:24 -0700 Subject: [PATCH] Fix utils test since docstring was used in test itself Ignore the D401 error instead. --- tests/test_cliUtils.py | 10 +++++----- tests/test_flake8.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 tests/test_flake8.py diff --git a/tests/test_cliUtils.py b/tests/test_cliUtils.py index 498d9260f2..1f7faff4d6 100644 --- a/tests/test_cliUtils.py +++ b/tests/test_cliUtils.py @@ -51,7 +51,7 @@ def testHelp(self): @repo_argument(help="repo help text") @directory_argument(help="directory help text") def cli(): - """Return the cli help message.""" + """The cli help message.""" # noqa: D401 pass self.runTest(cli) @@ -63,7 +63,7 @@ def testHelpWrapped(self): @repo_argument(help="repo help text") @directory_argument(help="directory help text") def cli(): - """Return the cli help message.""" + """The cli help message.""" # noqa: D401 pass self.runTest(cli) @@ -199,9 +199,9 @@ def test_help(self): arguments are declared. Verify that MWArgument adds " ..." after the option metavar when - `nargs` != 1. The default behavior of click is to add elipsis when - nargs does not equal 1, but it does not put a space before the elipsis - and we prefer a space between the metavar and the elipsis. + `nargs` != 1. The default behavior of click is to add ellipsis when + nargs does not equal 1, but it does not put a space before the ellipsis + and we prefer a space between the metavar and the ellipsis. """ # nargs can be -1 for any number of args, or >= 1 for a specified # number of arguments. diff --git a/tests/test_flake8.py b/tests/test_flake8.py new file mode 100644 index 0000000000..2a64c6e16b --- /dev/null +++ b/tests/test_flake8.py @@ -0,0 +1,30 @@ +# This file is part of utils. +# +# Developed for the LSST Data Management System. +# This product includes software developed by the LSST Project +# (https://www.lsst.org). +# See the COPYRIGHT file at the top-level directory of this distribution +# for details of code ownership. +# +# Use of this source code is governed by a 3-clause BSD-style +# license that can be found in the LICENSE file. + +import os +import sys +import unittest + +import lsst.utils.tests + +SCANDIR = os.path.realpath(os.path.join(os.path.dirname(__file__), os.path.pardir)) + + +class Flake8TestCase(lsst.utils.tests.ExecutablesTestCase): + def test_flake8(self): + """Run flake8 on the source code starting in the parent directory.""" + self.assertExecutable( + sys.executable, args=["-m", "flake8", "-j", "auto", f"{SCANDIR}"], msg="Code failed flake8 check." + ) + + +if __name__ == "__main__": + unittest.main()