faker icon indicating copy to clipboard operation
faker copied to clipboard

Add option to silence deprecation warnings when running the tests

Open stefannibrasil opened this issue 9 months ago • 4 comments

We have recently introduced an internal deprecator for faker. See #2858 and #2919 for more details.

We'd like to have the option to skip printing out the deprecation warnings when running the tests. Currently, we get a long test output due to them.

Ruby's Deprecate gem has the option to wrap a test assertion in a skip_during block, intended to be used in the test suite only:

class TestSomething < Gem::Testcase
  def test_some_thing_with_deprecations
    Gem::Deprecate.skip_during do
      actual_stdout, actual_stderr = capture_output do
        Gem.something_deprecated
      end
      assert_empty actual_stdout
      assert_equal(expected, actual_stderr)
    end
  end
end

It would be nice if we could have a similar option for our custom deprecator so our test output is not filled with those deprecation messages while they are being removed.

stefannibrasil avatar Apr 30 '24 00:04 stefannibrasil