Skip to content

Commit 0eb9ef4

Browse files
committed
Merge branch 'xylar/fix-non-editable-install' into develop
2 parents a2d7962 + a910bf7 commit 0eb9ef4

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

mpas_analysis/__main__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,9 @@ def get_editable_install_dir(package_name):
943943

944944
direct_url = Distribution.from_name(package_name).read_text(
945945
'direct_url.json')
946+
if direct_url is None:
947+
return None
948+
946949
contents = json.loads(direct_url)
947950
pkg_is_editable = contents.get("dir_info", {}).get("editable", False)
948951
if pkg_is_editable and 'url' in contents:

mpas_analysis/test/test_main.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# This software is open source software available under the BSD-3 license.
2+
#
3+
# Copyright (c) 2022 Triad National Security, LLC. All rights reserved.
4+
# Copyright (c) 2022 Lawrence Livermore National Security, LLC. All rights
5+
# reserved.
6+
# Copyright (c) 2022 UT-Battelle, LLC. All rights reserved.
7+
#
8+
# Additional copyright and license information can be found in the LICENSE file
9+
# distributed with this code, or at
10+
# https://raw.githubusercontent.com/MPAS-Dev/MPAS-Analysis/main/LICENSE
11+
"""
12+
Regression tests for helpers in ``mpas_analysis.__main__``.
13+
"""
14+
15+
import os
16+
from unittest.mock import Mock, patch
17+
18+
from mpas_analysis.test import TestCase
19+
20+
21+
# Importing mpas_analysis.__main__ triggers matplotlib imports in some test
22+
# environments, so use a writable cache directory.
23+
os.environ.setdefault('MPLCONFIGDIR', '/tmp/matplotlib')
24+
25+
import mpas_analysis.__main__ as main
26+
27+
28+
class TestMain(TestCase):
29+
def test_get_editable_install_dir_without_direct_url(self):
30+
distribution = Mock()
31+
distribution.read_text.return_value = None
32+
33+
with patch.object(main.Distribution, 'from_name',
34+
return_value=distribution):
35+
self.assertEqual(main.get_editable_install_dir('mpas_analysis'),
36+
None)

0 commit comments

Comments
 (0)