Skip to content

Commit

Permalink
Fix get_clean_hydrad when using a local copy (#166)
Browse files Browse the repository at this point in the history
* use shutil for copying dirs

* add tests for configure.util
  • Loading branch information
wtbarnes authored Dec 8, 2023
1 parent a5927f5 commit f8b615f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 13 additions & 0 deletions pydrad/configure/tests/test_util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import pytest

from pydrad.configure.util import get_clean_hydrad


def test_clean_hydrad_from_local(tmpdir_factory, hydrad):
new_hydrad_copy = tmpdir_factory.mktemp('new_hydrad')
get_clean_hydrad(new_hydrad_copy, base_path=hydrad, from_github=False, overwrite=True)


def test_clean_hydrad_no_args_raises_error():
with pytest.raises(ValueError, match='Specify local path to HYDRAD or clone from GitHub'):
get_clean_hydrad('foo', base_path=None, from_github=False)
3 changes: 1 addition & 2 deletions pydrad/configure/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import stat
import subprocess
import tempfile
from distutils.dir_util import copy_tree

import astropy.units as u

Expand Down Expand Up @@ -118,7 +117,7 @@ def _handle_readonly(func, path, exc_info):
git.Repo.clone_from('https://github.com/rice-solar-physics/HYDRAD',
tmpdir)
elif base_path:
copy_tree(base_path, tmpdir)
shutil.copytree(base_path, tmpdir, dirs_exist_ok=True)
else:
raise ValueError('Specify local path to HYDRAD or clone from GitHub')
rm_dirs = [
Expand Down

0 comments on commit f8b615f

Please sign in to comment.