Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
set_args in deprecation unit test + use renamed flags as globals
  • Loading branch information
MichelleArk authored and ChenyuLInx committed Feb 7, 2023
commit 196efac91a46de050f39daa7b46a06ac696c07e5
2 changes: 0 additions & 2 deletions core/dbt/cli/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
# TODO anything that has a default in params should be removed here?
# Or maybe only the ones that's in the root click group
FLAGS_DEFAULTS = {
"SEND_ANONYMOUS_USAGE_STATS": True,
"INDIRECT_SELECTION": "eager",
"NO_PRINT": False,
"TARGET_PATH": None,
# cli args without user_config or env var option
"FULL_REFRESH": False,
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/context/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ def print(msg: str) -> str:
{% endmacro %}"
"""

if not get_flags().NO_PRINT:
if not get_flags().PRINT:
print(msg)
return ""

Expand Down
2 changes: 1 addition & 1 deletion core/dbt/contracts/graph/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def __post_init__(self):
self.user_id = tracking.active_user.id

if self.send_anonymous_usage_stats is None:
self.send_anonymous_usage_stats = get_flags().SEND_ANONYMOUS_USAGE_STATS
self.send_anonymous_usage_stats = get_flags().ANONYMOUS_USAGE_STATS

@classmethod
def default(cls):
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/test_deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from dbt.internal_deprecations import deprecated
import dbt.exceptions
from dbt.node_types import NodeType
from dbt.flags import set_from_args
from argparse import Namespace


@deprecated(reason="just because", version="1.23.0", suggested_action="Make some updates")
Expand All @@ -13,6 +15,7 @@ def to_be_decorated():

# simpletest that the return value is not modified
def test_deprecated_func():
set_from_args(Namespace(WARN_ERROR=False), None)
assert hasattr(to_be_decorated, "__wrapped__")
assert to_be_decorated() == 5

Expand All @@ -27,6 +30,10 @@ def test_warn(self):


class TestDeprecatedExceptionFunctions:
@pytest.fixture(scope="class", autouse=True)
def setUp(self):
set_from_args(Namespace(WARN_ERROR=False), None)

def runFunc(self, func, *args):
return func(*args)

Expand Down