Skip to content

Commit

Permalink
Merge pull request #543 from render-engine:531-AttributeError-str-obj…
Browse files Browse the repository at this point in the history
…ect-has-no-attribute-exists

Fix clean folder function
  • Loading branch information
kjaymiller committed Jan 22, 2024
2 parents 9df89d0 + 03aa43d commit cc085b9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/render_engine/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def build(
module, site = module_site
app = get_app(module, site)
if clean:
remove_output_folder(app.output_path)
remove_output_folder(pathlib.Path(app.output_path))
app.render()


Expand Down Expand Up @@ -250,7 +250,7 @@ def serve(
app = get_app(module, site)

if clean:
remove_output_folder(app.output_path)
remove_output_folder(pathlib.Path(app.output_path))
app.render()

if not directory:
Expand Down
17 changes: 17 additions & 0 deletions tests/tests_cli/test_render_engine_tools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import pathlib
import pytest
from render_engine.cli.cli import remove_output_folder

from render_engine.site import Site

def test_clean_folder(tmp_path):
site = Site()
site.output_path = tmp_path
dirty_output_path = tmp_path / "test" # Tests that nested folders are also removed
dirty_output_path.mkdir()
dirty_output_path.joinpath("test.txt").touch()
assert dirty_output_path.exists()

remove_output_folder(pathlib.Path(dirty_output_path))
assert not dirty_output_path.exists()
assert not list(tmp_path.iterdir())

0 comments on commit cc085b9

Please sign in to comment.