Skip to content

Commit

Permalink
Fix test_can_silence tests in test_warn_error_options.py to ensur…
Browse files Browse the repository at this point in the history
…e silencing

We're fixing an issue wherein `silence` specifications in the `dbt_project.yaml`
weren't being respected. This was odd since we had tests specifically for this.
It turns out the tests were broken. Essentially the warning was instead being raised
as an error due to `include: 'all'`. Then because it was being raised as an error,
the event wasn't going through the logger. We were only asserting in these tests that
the silenced event wasn't going through the logger (which it wasn't) so everything
"appeared" to be working. Unfortunately everything wasn't actually working. This is now
highlighted because `test_warn_error_options::TestWarnErrorOptionsFromProject:test_can_silence`
is now failing with this commit.
  • Loading branch information
QMalcolm committed Jun 24, 2024
1 parent d389ff1 commit cb89f0e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions tests/functional/configs/test_warn_error_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ def test_can_silence(self, project, catcher: EventCatcher, runner: dbtRunner) ->
assert_deprecation_warning(result, catcher)

catcher.flush()
runner.invoke(
["run", "--warn-error-options", "{'include': 'all', 'silence': ['DeprecatedModel']}"]
)
result = runner.invoke(["run", "--warn-error-options", "{'silence': ['DeprecatedModel']}"])
assert result.success
assert len(catcher.caught_events) == 0

def test_can_raise_warning_to_error(
Expand Down Expand Up @@ -131,13 +130,12 @@ def test_can_silence(
result = runner.invoke(["run"])
assert_deprecation_warning(result, catcher)

silence_options = {
"flags": {"warn_error_options": {"include": "all", "silence": ["DeprecatedModel"]}}
}
silence_options = {"flags": {"warn_error_options": {"silence": ["DeprecatedModel"]}}}
update_config_file(silence_options, project_root, "dbt_project.yml")

catcher.flush()
runner.invoke(["run"])
result = runner.invoke(["run"])
assert result.success
assert len(catcher.caught_events) == 0

def test_can_raise_warning_to_error(
Expand Down

0 comments on commit cb89f0e

Please sign in to comment.