Skip to content

Commit

Permalink
try: fix permission issue w up_one
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelleArk committed Oct 9, 2023
1 parent bb92c04 commit 3b23a51
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
12 changes: 7 additions & 5 deletions tests/functional/partial_parsing/test_partial_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
run_dbt_and_capture,
rename_dir,
)
from tests.functional.utils import up_one
from dbt.tests.fixtures.project import write_project_files
from tests.functional.partial_parsing.fixtures import (
model_one_sql,
Expand Down Expand Up @@ -881,11 +882,12 @@ def local_dependency_files(self):
}

def rename_project_root(self, project, new_project_root):
rename_dir(project.project_root, new_project_root)
project.project_root = new_project_root
# flags.project_dir is set during the project test fixture, and is persisted across run_dbt calls,
# so it needs to be reset between invocations
flags.set_from_args(Namespace(PROJECT_DIR=new_project_root), None)
with up_one(new_project_root):
rename_dir(project.project_root, new_project_root)
project.project_root = new_project_root
# flags.project_dir is set during the project test fixture, and is persisted across run_dbt calls,
# so it needs to be reset between invocations
flags.set_from_args(Namespace(PROJECT_DIR=new_project_root), None)

@pytest.fixture(scope="class", autouse=True)
def initial_run_and_rename_project_dir(self, project, local_dependency_files):
Expand Down
5 changes: 3 additions & 2 deletions tests/functional/utils.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import os
from contextlib import contextmanager
from typing import Optional
from pathlib import Path


@contextmanager
def up_one():
def up_one(return_path: Optional[Path] = None):
current_path = Path.cwd()
os.chdir("../")
try:
yield
finally:
os.chdir(current_path)
os.chdir(return_path or current_path)

0 comments on commit 3b23a51

Please sign in to comment.