Skip to content

Commit

Permalink
Rename test option to stop confusing the test system
Browse files Browse the repository at this point in the history
On python 3.11 the previous code gave a warning:

tests/test_cliUtils.py::MWOptionDecoratorTest::test_option
   .../python3.11/unittest/case.py:678: DeprecationWarning: It is deprecated to return a value
           that is not None from a test case (<lsst.daf.butler.cli.utils.MWOptionDecorator object at 0x2ae76e790>)
   return self.run(*args, **kwds)
  • Loading branch information
timj committed Jun 20, 2023
1 parent ea43211 commit a5b73f5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/test_cliUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,22 +241,22 @@ def cli(things):
class MWOptionDecoratorTest(unittest.TestCase):
"""Tests for the MWOptionDecorator class."""

test_option = MWOptionDecorator("-t", "--test", multiple=True)
_test_option = MWOptionDecorator("-t", "--test", multiple=True)

def testGetName(self):
"""Test getting the option name from the MWOptionDecorator."""
self.assertEqual(self.test_option.name(), "test")
self.assertEqual(self._test_option.name(), "test")

def testGetOpts(self):
"""Test getting the option flags from the MWOptionDecorator."""
self.assertEqual(self.test_option.opts(), ["-t", "--test"])
self.assertEqual(self._test_option.opts(), ["-t", "--test"])

def testUse(self):
"""Test using the MWOptionDecorator with a command."""
mock = MagicMock()

@click.command()
@self.test_option()
@self._test_option()
def cli(test):
mock(test)

Expand All @@ -271,7 +271,7 @@ def testOverride(self):
mock = MagicMock()

@click.command()
@self.test_option(multiple=False)
@self._test_option(multiple=False)
def cli(test):
mock(test)

Expand Down

0 comments on commit a5b73f5

Please sign in to comment.