Skip to content

Commit d409e15

Browse files
committed
tweak/simplify dependency downloader and improve test coverage
1 parent 633e7f8 commit d409e15

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

open_fortran_parser/dependencies.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def ensure_dependencies(
2121
os.makedirs(str(target_dir), exist_ok=True)
2222
for dependency, (url_root, filename) in dependencies.items():
2323
path = target_dir.joinpath(filename)
24-
if path.is_file():
24+
if path.is_file() and not silent:
2525
_LOG.warning('%s is present already.', dependency)
2626
continue
2727
if not download:
@@ -32,13 +32,6 @@ def ensure_dependencies(
3232
wget.download(url, str(path), bar=None if silent else wget.bar_adaptive)
3333
if not silent:
3434
print()
35-
if not silent:
36-
classpath = target_dir.joinpath('*')
37-
_LOG.warning('If you wish to use the Open Fortran Parser XML generator directly,'
38-
' please add "%s" to your Java classpath:', classpath)
39-
if platform.system() != 'Windows':
40-
_LOG.warning('export CLASSPATH="${CLASSPATH}:%s"', classpath)
41-
4235

4336
def cleanup_old_dependencies(
4437
outdated_dependencies, current_dir: pathlib.Path,

test/test_dependencies.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ class Tests(unittest.TestCase):
1818
@unittest.skipUnless(os.environ.get('TEST_DEPENDENCIES'), 'skipping dependency test')
1919
def test_deps(self):
2020
with tempfile.TemporaryDirectory() as temp_dir:
21-
ensure_dependencies(DEV_DEPENDENCIES, pathlib.Path(temp_dir), silent=False)
21+
self.assertEqual(len(os.listdir(temp_dir)), 0)
22+
ensure_dependencies(TESTED_DEPENDENCIES, pathlib.Path(temp_dir), download=False)
23+
self.assertEqual(len(os.listdir(temp_dir)), 0)
24+
ensure_dependencies(TESTED_DEPENDENCIES, pathlib.Path(temp_dir), silent=False)
2225
self.assertGreater(len(os.listdir(temp_dir)), 0)
26+
ensure_dependencies(TESTED_DEPENDENCIES, pathlib.Path(temp_dir), silent=False)
2327
with tempfile.TemporaryDirectory() as temp_dir:
2428
os.rmdir(temp_dir)
25-
ensure_dependencies(DEV_DEPENDENCIES, pathlib.Path(temp_dir), silent=True)
29+
ensure_dependencies(TESTED_DEPENDENCIES, pathlib.Path(temp_dir), silent=True)
2630
self.assertGreater(len(os.listdir(temp_dir)), 0)
2731

2832
@unittest.skipUnless(os.environ.get('TEST_DEPENDENCIES'), 'skipping dependency test')

0 commit comments

Comments
 (0)