Skip to content

Commit

Permalink
Refactor test_pages_folder path tests to single parameterised test
Browse files Browse the repository at this point in the history
  • Loading branch information
ned2 committed Jan 26, 2023
1 parent 76d949d commit 3857c2e
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions tests/unit/pages/test_pages_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ def does_not_raise():
False,
str(THIS_DIR / "custom_pages"),
),
("sub_dir/custom_pages", True, str(THIS_DIR / "sub_dir" / "custom_pages")),
],
)
def test_pages_folder_path_config(
def test_pages_folder_config(
empty_environ, pages_folder, use_pages, expected_pages_folder_path
):
pages_folder_path = pages_folder_config(__name__, pages_folder, use_pages)
Expand All @@ -63,19 +64,18 @@ def test_pages_missing_path_config(empty_environ, pages_folder, use_pages, expec
_ = pages_folder_config(__name__, pages_folder, use_pages)


def test_pages_custom_path_config(empty_environ, clear_pages_state):
app = Dash(__name__, pages_folder="custom_pages")
assert app.use_pages


def test_pages_pathlib_config(empty_environ, clear_pages_state):
app = Dash(__name__, pages_folder=Path("custom_pages"))
assert app.use_pages
assert app.pages_folder == "custom_pages"


def test_pages_absolute_path_config(empty_environ, clear_pages_state):
pages_path = str(THIS_DIR / "custom_pages")
app = Dash(__name__, pages_folder=pages_path)
@pytest.mark.parametrize(
"pages_folder",
[
"custom_pages",
Path("custom_pages"),
str(THIS_DIR / "custom_pages"),
THIS_DIR / "custom_pages",
str(THIS_DIR / "sub_dir" / "custom_pages"),
THIS_DIR / "sub_dir" / "custom_pages",
],
)
def test_pages_folder_app_config(empty_environ, clear_pages_state, pages_folder):
app = Dash(__name__, pages_folder=pages_folder)
assert app.use_pages
assert app.pages_folder == pages_path
assert app.pages_folder == str(pages_folder)

0 comments on commit 3857c2e

Please sign in to comment.