diff --git a/tests/test_build_system.py b/tests/test_build_system.py index 772a3d3..52d379d 100644 --- a/tests/test_build_system.py +++ b/tests/test_build_system.py @@ -26,8 +26,7 @@ from kas import kas def test_build_system(changedir, tmpdir): - tdir = str(tmpdir.mkdir('test_build_system')) - shutil.rmtree(tdir, ignore_errors=True) + tdir = str(tmpdir / 'test_build_system') shutil.copytree('tests/test_build_system', tdir) os.chdir(tdir) diff --git a/tests/test_environment_variables.py b/tests/test_environment_variables.py index cb91b6f..ab46d34 100644 --- a/tests/test_environment_variables.py +++ b/tests/test_environment_variables.py @@ -29,8 +29,7 @@ from kas import kas def test_build_dir_is_placed_inside_work_dir_by_default(changedir, tmpdir): - conf_dir = str(tmpdir.mkdir('test_env_variables')) - shutil.rmtree(conf_dir, ignore_errors=True) + conf_dir = str(tmpdir / 'test_env_variables') shutil.copytree('tests/test_environment_variables', conf_dir) os.chdir(conf_dir) @@ -41,11 +40,9 @@ def test_build_dir_is_placed_inside_work_dir_by_default(changedir, tmpdir): def test_build_dir_can_be_specified_by_environment_variable(changedir, tmpdir): - conf_dir = str(tmpdir.mkdir('test_env_variables')) - build_dir = str(tmpdir.mkdir('test_build_dir')) - shutil.rmtree(conf_dir, ignore_errors=True) + conf_dir = str(tmpdir / 'test_env_variables') + build_dir = str(tmpdir / 'test_build_dir') shutil.copytree('tests/test_environment_variables', conf_dir) - shutil.rmtree(build_dir, ignore_errors=True) os.chdir(conf_dir) os.environ['KAS_BUILD_DIR'] = build_dir @@ -56,12 +53,11 @@ def test_build_dir_can_be_specified_by_environment_variable(changedir, tmpdir): def _test_env_section_export(changedir, tmpdir, bb_env_var, bb_repo): - conf_dir = pathlib.Path(str(tmpdir.mkdir('test_env_variables'))) + conf_dir = pathlib.Path(str(tmpdir / 'test_env_variables')) env_out = conf_dir / 'env_out' bb_env_out = conf_dir / 'bb_env_out' init_build_env = conf_dir / 'oe-init-build-env' - shutil.rmtree(str(conf_dir), ignore_errors=True) shutil.copytree('tests/test_environment_variables', str(conf_dir)) os.chdir(str(conf_dir)) diff --git a/tests/test_layers.py b/tests/test_layers.py index a370daa..0e7e0ab 100644 --- a/tests/test_layers.py +++ b/tests/test_layers.py @@ -31,8 +31,7 @@ LAYERBASE = '${TOPDIR}/..' @pytest.fixture def dokas(tmpdir): - tdir = str(tmpdir.mkdir('test_layers')) - shutil.rmtree(tdir, ignore_errors=True) + tdir = str(tmpdir / 'test_layers') shutil.copytree('tests/test_layers', tdir) os.chdir(tdir) kas.kas(['shell', 'test.yml', '-c', 'true']) diff --git a/tests/test_menu.py b/tests/test_menu.py index e67aed2..4382470 100644 --- a/tests/test_menu.py +++ b/tests/test_menu.py @@ -55,8 +55,7 @@ def check_bitbake_options(expected): def test_menu(monkeypatch, tmpdir): - tdir = str(tmpdir.mkdir('test_menu')) - shutil.rmtree(tdir, ignore_errors=True) + tdir = str(tmpdir / 'test_menu') shutil.copytree('tests/test_menu', tdir) cwd = os.getcwd() os.chdir(tdir) diff --git a/tests/test_patch.py b/tests/test_patch.py index 610d6cc..e762191 100644 --- a/tests/test_patch.py +++ b/tests/test_patch.py @@ -27,8 +27,7 @@ from kas import kas def test_patch(changedir, tmpdir): - tdir = str(tmpdir.mkdir('test_patch')) - shutil.rmtree(tdir, ignore_errors=True) + tdir = str(tmpdir / 'test_patch') shutil.copytree('tests/test_patch', tdir) cwd = os.getcwd() os.chdir(tdir) @@ -45,8 +44,7 @@ def test_patch_update(changedir, tmpdir): a branch to a commit hash and vice-versa with both git and mercurial repositories. """ - tdir = str(tmpdir.mkdir('test_patch_update')) - shutil.rmtree(tdir, ignore_errors=True) + tdir = str(tmpdir / 'test_patch_update') shutil.copytree('tests/test_patch', tdir) cwd = os.getcwd() os.chdir(tdir) diff --git a/tests/test_refspec.py b/tests/test_refspec.py index b942969..53aebd7 100644 --- a/tests/test_refspec.py +++ b/tests/test_refspec.py @@ -32,8 +32,7 @@ def test_refspec_switch(changedir, tmpdir): Test that the local git clone is correctly updated when switching between a commit hash refspec and a branch refspec. """ - tdir = str(tmpdir.mkdir('test_refspec_switch')) - shutil.rmtree(tdir, ignore_errors=True) + tdir = str(tmpdir / 'test_refspec_switch') shutil.copytree('tests/test_refspec', tdir) os.chdir(tdir) @@ -71,8 +70,7 @@ def test_refspec_absolute(changedir, tmpdir): Test that the local git clone works when a absolute refspec is given. """ - tdir = str(tmpdir.mkdir('test_refspec_absolute')) - shutil.rmtree(tdir, ignore_errors=True) + tdir = str(tmpdir / 'test_refspec_absolute') shutil.copytree('tests/test_refspec', tdir) os.chdir(tdir) @@ -94,8 +92,7 @@ def test_url_no_refspec(changedir, tmpdir): """ Test that a repository with url but no refspec raises an error. """ - tdir = str(tmpdir.mkdir('test_url_no_refspec')) - shutil.rmtree(tdir, ignore_errors=True) + tdir = str(tmpdir / 'test_url_no_refspec') shutil.copytree('tests/test_refspec', tdir) os.chdir(tdir) with pytest.raises(SystemExit):