Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-28984

Fix salobj unit test failure on Jenkins

    XMLWordPrintable

    Details

    • Story Points:
      0
    • Epic Link:
    • Sprint:
      TSSW Sprint - Mar 1 - Mar 15
    • Team:
      Telescope and Site
    • Urgent?:
      Yes

      Description

      Rob reports the following error on a salobj Jenkins build:

      _______________ TestCscConstructorTestCase.test_missing_version ________________
      self = <test_csc_constructor.TestCscConstructorTestCase testMethod=test_missing_version>
          async def test_missing_version(self):
              class MissingVersionCsc(salobj.BaseCsc):
                  """A do-nothing CSC with no version class variable.
                  """
                  valid_simulation_modes = [0]
                  def __init__(self, index):
                      for attr_name in dir(salobj.TestCsc):
                          if attr_name.startswith("do_"):
                              setattr(self, attr_name, self.noop)
                      super().__init__(index=index, name="Test")
                  async def noop(self, *args, **kwargs):
                      pass
              mv = None
              try:
                  with self.assertWarns(DeprecationWarning):
                      mv = MissingVersionCsc(index=next(index_gen))
              finally:
                  if mv is not None:
                      await mv.close()
              # Adding the version attribute should eliminate the warning
              MissingVersionCsc.version = "foo"
              mv = None
              try:
                  with self.assertRaises(AssertionError):
                      with self.assertWarns(DeprecationWarning):
      >                   mv = MissingVersionCsc(index=next(index_gen))
      E                   AssertionError: AssertionError not raised
      tests/test_csc_constructor.py:181: AssertionError
      

      The only explanation I can think of is that some unknown code is raising a DeprecationWarning for reasons unrelated to the cause I am testing.

        Attachments

          Activity

          Hide
          rowen Russell Owen added a comment - - edited

          It turns out I was using assertWarns in many places without checking that the correct message was seen, so I updated all of those to use assertWarnsRegex, which allows specifying the expected message. This properly handles unexpected extra deprecation warnings that have nothing to do with the tests.

          Pull request: https://github.com/lsst-ts/ts_salobj/pull/181

          Show
          rowen Russell Owen added a comment - - edited It turns out I was using assertWarns in many places without checking that the correct message was seen, so I updated all of those to use assertWarnsRegex, which allows specifying the expected message. This properly handles unexpected extra deprecation warnings that have nothing to do with the tests. Pull request: https://github.com/lsst-ts/ts_salobj/pull/181
          Hide
          cwinslow Colin Winslow [X] (Inactive) added a comment -

          Looks good

          Show
          cwinslow Colin Winslow [X] (Inactive) added a comment - Looks good
          Hide
          rowen Russell Owen added a comment -

          Tagged as v6.3.0.beta.2

          Show
          rowen Russell Owen added a comment - Tagged as v6.3.0.beta.2

            People

            Assignee:
            rowen Russell Owen
            Reporter:
            rowen Russell Owen
            Reviewers:
            Colin Winslow [X] (Inactive)
            Watchers:
            Colin Winslow [X] (Inactive), Rob Bovill, Russell Owen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Jenkins

                No builds found.