Uploaded image for project: 'Nuxeo Drive '
  1. Nuxeo Drive
  2. NXDRIVE-1336

Catch warnings when running tests

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.1.1
    • Fix Version/s: 4.0.0
    • Component/s: Tests

      Description

      If there is any warning when running a test, it must fail.
      This will help preventing the use of deprecated/obsolete functions and to ensure a good use of the language (not comparing bytes against strings for instance, or prevent file leaks).

      This can be easily done with that pytest fixture:

      @pytest.fixture(autouse=True)
      def no_warnings(recwarn):
          """Fail on warning."""
      
          yield
      
          warnings = []
          for warning in recwarn:  # pragma: no cover
              message = str(warning.message)
              # ImportWarning: Not importing directory '...' missing __init__(.py)
              if not (
                  isinstance(warning.message, ImportWarning)
                  and message.startswith("Not importing directory ")
                  and " missing __init__" in message
              ):
                  warnings.append(f"{warning.filename}:{warning.lineno} {message}")
          assert not warnings
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 15 minutes
                15m