diff --git a/tests/unit_tests/test_tethys_cli/test_scaffold_commands.py b/tests/unit_tests/test_tethys_cli/test_scaffold_commands.py index 3cb85da81..ac1a6a004 100644 --- a/tests/unit_tests/test_tethys_cli/test_scaffold_commands.py +++ b/tests/unit_tests/test_tethys_cli/test_scaffold_commands.py @@ -122,7 +122,7 @@ def test_render_path(self): @mock.patch("tethys_cli.scaffold_commands.Path.is_dir") @mock.patch("tethys_cli.scaffold_commands.shutil.rmtree") @mock.patch("tethys_cli.scaffold_commands.render_path") - @mock.patch("tethys_cli.scaffold_commands.Path.walk") + @mock.patch("tethys_cli.scaffold_commands.walk") @mock.patch("tethys_cli.scaffold_commands.Path.mkdir") @mock.patch("tethys_cli.scaffold_commands.Path.read_text") @mock.patch("tethys_cli.scaffold_commands.Path.write_text") @@ -133,7 +133,7 @@ def test_scaffold_command( __, ___, mock_mkdir, - mock_path_walk, + mock_os_walk, mock_render_path, mock_rmt, mock_is_dir, @@ -163,7 +163,7 @@ def test_scaffold_command( mock_render_path.return_value = "" - mock_path_walk.return_value = [ + mock_os_walk.return_value = [ (Path("/").absolute() / "foo", ("bar",), ("baz",)), (Path("/").absolute() / "foo" / "bar", (), ("spam", "eggs_tmpl")), ] @@ -267,7 +267,7 @@ def test_scaffold_command_with_not_valid_template( @mock.patch("tethys_cli.scaffold_commands.Path.is_dir") @mock.patch("tethys_cli.scaffold_commands.shutil.rmtree") @mock.patch("tethys_cli.scaffold_commands.render_path") - @mock.patch("tethys_cli.scaffold_commands.Path.walk") + @mock.patch("tethys_cli.scaffold_commands.walk") @mock.patch("tethys_cli.scaffold_commands.Path.mkdir") @mock.patch("tethys_cli.scaffold_commands.Path.read_text") @mock.patch("tethys_cli.scaffold_commands.Path.write_text") @@ -278,7 +278,7 @@ def test_scaffold_command_with_no_extension( __, ___, mock_mkdir, - mock_path_walk, + mock_os_walk, mock_render_path, mock_rmt, mock_is_dir, @@ -307,7 +307,7 @@ def test_scaffold_command_with_no_extension( mock_render_path.return_value = "" - mock_path_walk.return_value = [ + mock_os_walk.return_value = [ (Path("/").absolute() / "foo", ("bar",), ("baz",)), (Path("/").absolute() / "foo" / "bar", (), ("spam", "eggs_tmpl")), ] @@ -369,7 +369,7 @@ def test_scaffold_command_with_no_extension( @mock.patch("tethys_cli.scaffold_commands.Path.is_dir") @mock.patch("tethys_cli.scaffold_commands.shutil.rmtree") @mock.patch("tethys_cli.scaffold_commands.render_path") - @mock.patch("tethys_cli.scaffold_commands.Path.walk") + @mock.patch("tethys_cli.scaffold_commands.walk") @mock.patch("tethys_cli.scaffold_commands.Path.mkdir") @mock.patch("tethys_cli.scaffold_commands.Path.read_text") @mock.patch("tethys_cli.scaffold_commands.Path.write_text") @@ -380,7 +380,7 @@ def test_scaffold_command_with_uppercase_project_name( __, ___, mock_mkdir, - mock_path_walk, + mock_os_walk, mock_render_path, mock_rmt, mock_is_dir, @@ -410,7 +410,7 @@ def test_scaffold_command_with_uppercase_project_name( mock_render_path.return_value = "" - mock_path_walk.return_value = [ + mock_os_walk.return_value = [ (Path("/").absolute() / "foo", ("bar",), ("baz",)), (Path("/").absolute() / "foo" / "bar", (), ("spam", "eggs_tmpl")), ] @@ -519,7 +519,7 @@ def test_scaffold_command_with_wrong_project_name( @mock.patch("tethys_cli.scaffold_commands.Path.is_dir") @mock.patch("tethys_cli.scaffold_commands.shutil.rmtree") @mock.patch("tethys_cli.scaffold_commands.render_path") - @mock.patch("tethys_cli.scaffold_commands.Path.walk") + @mock.patch("tethys_cli.scaffold_commands.walk") @mock.patch("tethys_cli.scaffold_commands.Path.mkdir") @mock.patch("tethys_cli.scaffold_commands.Path.read_text") @mock.patch("tethys_cli.scaffold_commands.Path.write_text") @@ -530,7 +530,7 @@ def test_scaffold_command_with_project_warning( __, ___, mock_mkdir, - mock_path_walk, + mock_os_walk, mock_render_path, mock_rmt, mock_is_dir, @@ -559,7 +559,7 @@ def test_scaffold_command_with_project_warning( mock_render_path.return_value = "" - mock_path_walk.return_value = [ + mock_os_walk.return_value = [ (Path("/").absolute() / "foo", ("bar",), ("baz",)), (Path("/").absolute() / "foo" / "bar", (), ("spam", "eggs_tmpl")), ] @@ -628,7 +628,7 @@ def test_scaffold_command_with_project_warning( @mock.patch("tethys_cli.scaffold_commands.Path.is_dir") @mock.patch("tethys_cli.scaffold_commands.shutil.rmtree") @mock.patch("tethys_cli.scaffold_commands.render_path") - @mock.patch("tethys_cli.scaffold_commands.Path.walk") + @mock.patch("tethys_cli.scaffold_commands.walk") @mock.patch("tethys_cli.scaffold_commands.Path.mkdir") @mock.patch("tethys_cli.scaffold_commands.Path.read_text") @mock.patch("tethys_cli.scaffold_commands.Path.write_text") @@ -639,7 +639,7 @@ def test_scaffold_command_with_no_defaults( __, ___, mock_mkdir, - mock_path_walk, + mock_os_walk, mock_render_path, mock_rmt, mock_is_dir, @@ -670,7 +670,7 @@ def test_scaffold_command_with_no_defaults( mock_render_path.return_value = "" - mock_path_walk.return_value = [ + mock_os_walk.return_value = [ (Path("/").absolute() / "foo", ("bar",), ("baz",)), (Path("/").absolute() / "foo" / "bar", (), ("spam", "eggs_tmpl")), ] @@ -746,7 +746,7 @@ def test_scaffold_command_with_no_defaults( @mock.patch("tethys_cli.scaffold_commands.Path.is_dir") @mock.patch("tethys_cli.scaffold_commands.shutil.rmtree") @mock.patch("tethys_cli.scaffold_commands.render_path") - @mock.patch("tethys_cli.scaffold_commands.Path.walk") + @mock.patch("tethys_cli.scaffold_commands.walk") @mock.patch("tethys_cli.scaffold_commands.Path.mkdir") @mock.patch("tethys_cli.scaffold_commands.Path.read_text") @mock.patch("tethys_cli.scaffold_commands.Template") @@ -757,7 +757,7 @@ def test_scaffold_command_with_no_defaults_input_exception( _, __, mock_mkdir, - mock_path_walk, + mock_os_walk, mock_render_path, mock_rmt, mock_is_dir, @@ -788,7 +788,7 @@ def test_scaffold_command_with_no_defaults_input_exception( mock_render_path.return_value = "" - mock_path_walk.return_value = [ + mock_os_walk.return_value = [ (Path("/").absolute() / "foo", ("bar",), ("baz",)), (Path("/").absolute() / "foo" / "bar", (), ("spam", "eggs")), ] @@ -841,7 +841,7 @@ def test_scaffold_command_with_no_defaults_input_exception( @mock.patch("tethys_cli.scaffold_commands.Path.is_dir") @mock.patch("tethys_cli.scaffold_commands.shutil.rmtree") @mock.patch("tethys_cli.scaffold_commands.render_path") - @mock.patch("tethys_cli.scaffold_commands.Path.walk") + @mock.patch("tethys_cli.scaffold_commands.walk") @mock.patch("tethys_cli.scaffold_commands.Path.mkdir") @mock.patch("tethys_cli.scaffold_commands.Path.read_text") @mock.patch("tethys_cli.scaffold_commands.Path.write_text") @@ -852,7 +852,7 @@ def test_scaffold_command_with_no_defaults_invalid_response( __, ___, mock_mkdir, - mock_path_walk, + mock_os_walk, mock_render_path, mock_rmt, mock_is_dir, @@ -884,7 +884,7 @@ def test_scaffold_command_with_no_defaults_invalid_response( mock_render_path.return_value = "" - mock_path_walk.return_value = [ + mock_os_walk.return_value = [ (Path("/").absolute() / "foo", ("bar",), ("baz",)), (Path("/").absolute() / "foo" / "bar", (), ("spam", "eggs_tmpl")), ] @@ -968,7 +968,7 @@ def test_scaffold_command_with_no_defaults_invalid_response( @mock.patch("tethys_cli.scaffold_commands.Path.is_dir") @mock.patch("tethys_cli.scaffold_commands.shutil.rmtree") @mock.patch("tethys_cli.scaffold_commands.render_path") - @mock.patch("tethys_cli.scaffold_commands.Path.walk") + @mock.patch("tethys_cli.scaffold_commands.walk") @mock.patch("tethys_cli.scaffold_commands.Path.mkdir") @mock.patch("tethys_cli.scaffold_commands.Path.read_text") @mock.patch("tethys_cli.scaffold_commands.Path.write_text") @@ -979,7 +979,7 @@ def test_scaffold_command_with_no_overwrite( __, ___, mock_mkdir, - mock_path_walk, + mock_os_walk, mock_render_path, mock_rmt, mock_is_dir, @@ -1010,7 +1010,7 @@ def test_scaffold_command_with_no_overwrite( mock_render_path.return_value = "" - mock_path_walk.return_value = [ + mock_os_walk.return_value = [ (Path("/").absolute() / "foo", ("bar",), ("baz",)), (Path("/").absolute() / "foo" / "bar", (), ("spam", "eggs_tmpl")), ] @@ -1081,7 +1081,7 @@ def test_scaffold_command_with_no_overwrite( @mock.patch("tethys_cli.scaffold_commands.Path.is_dir") @mock.patch("tethys_cli.scaffold_commands.shutil.rmtree") @mock.patch("tethys_cli.scaffold_commands.render_path") - @mock.patch("tethys_cli.scaffold_commands.Path.walk") + @mock.patch("tethys_cli.scaffold_commands.walk") @mock.patch("tethys_cli.scaffold_commands.Path.mkdir") @mock.patch("tethys_cli.scaffold_commands.Path.read_text") @mock.patch("tethys_cli.scaffold_commands.Template") @@ -1090,7 +1090,7 @@ def test_scaffold_command_with_no_overwrite_keyboard_interrupt( _, __, mock_mkdir, - mock_path_walk, + mock_os_walk, mock_render_path, mock_rmt, mock_is_dir, @@ -1121,7 +1121,7 @@ def test_scaffold_command_with_no_overwrite_keyboard_interrupt( mock_render_path.return_value = "" - mock_path_walk.return_value = [ + mock_os_walk.return_value = [ (Path("/").absolute() / "foo", ("bar",), ("baz",)), (Path("/").absolute() / "foo" / "bar", (), ("spam", "eggs")), ] @@ -1175,7 +1175,7 @@ def test_scaffold_command_with_no_overwrite_keyboard_interrupt( @mock.patch("tethys_cli.scaffold_commands.Path.is_dir") @mock.patch("tethys_cli.scaffold_commands.shutil.rmtree") @mock.patch("tethys_cli.scaffold_commands.render_path") - @mock.patch("tethys_cli.scaffold_commands.Path.walk") + @mock.patch("tethys_cli.scaffold_commands.walk") @mock.patch("tethys_cli.scaffold_commands.Path.mkdir") @mock.patch("tethys_cli.scaffold_commands.Path.read_text") @mock.patch("tethys_cli.scaffold_commands.Template") @@ -1184,7 +1184,7 @@ def test_scaffold_command_with_no_overwrite_cancel( _, __, mock_mkdir, - mock_path_walk, + mock_os_walk, mock_render_path, mock_rmt, mock_is_dir, @@ -1215,7 +1215,7 @@ def test_scaffold_command_with_no_overwrite_cancel( mock_render_path.return_value = "" - mock_path_walk.return_value = [ + mock_os_walk.return_value = [ (Path("/").absolute() / "foo", ("bar",), ("baz",)), (Path("/").absolute() / "foo" / "bar", (), ("spam", "eggs")), ] @@ -1269,7 +1269,7 @@ def test_scaffold_command_with_no_overwrite_cancel( @mock.patch("tethys_cli.scaffold_commands.Path.is_dir") @mock.patch("tethys_cli.scaffold_commands.shutil.rmtree") @mock.patch("tethys_cli.scaffold_commands.render_path") - @mock.patch("tethys_cli.scaffold_commands.Path.walk") + @mock.patch("tethys_cli.scaffold_commands.walk") @mock.patch("tethys_cli.scaffold_commands.Path.mkdir") @mock.patch("tethys_cli.scaffold_commands.Path.read_text") @mock.patch("tethys_cli.scaffold_commands.Template") @@ -1278,7 +1278,7 @@ def test_scaffold_command_with_no_overwrite_os_error( _, __, mock_mkdir, - mock_path_walk, + mock_os_walk, mock_render_path, mock_rmt, mock_is_dir, @@ -1309,7 +1309,7 @@ def test_scaffold_command_with_no_overwrite_os_error( mock_render_path.return_value = "" - mock_path_walk.return_value = [ + mock_os_walk.return_value = [ (Path("/").absolute() / "foo", ("bar",), ("baz",)), (Path("/").absolute() / "foo" / "bar", (), ("spam", "eggs")), ] diff --git a/tethys_cli/scaffold_commands.py b/tethys_cli/scaffold_commands.py index a3efa5a99..6870e75c3 100644 --- a/tethys_cli/scaffold_commands.py +++ b/tethys_cli/scaffold_commands.py @@ -2,6 +2,7 @@ import logging import random import shutil +from os import walk from pathlib import Path from jinja2 import Template @@ -417,7 +418,7 @@ def scaffold_command(args): exit(1) # Walk the template directory, creating the templates and directories in the new project as we go - for curr_template_root, _, template_files in template_root.walk(): + for curr_template_root, _, template_files in walk(template_root): curr_project_root = str(curr_template_root).replace( str(template_root), str(project_root) )