Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mpas_analysis/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,9 @@ def get_editable_install_dir(package_name):

direct_url = Distribution.from_name(package_name).read_text(
'direct_url.json')
if direct_url is None:
return None

contents = json.loads(direct_url)
pkg_is_editable = contents.get("dir_info", {}).get("editable", False)
if pkg_is_editable and 'url' in contents:
Expand Down
36 changes: 36 additions & 0 deletions mpas_analysis/test/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This software is open source software available under the BSD-3 license.
#
# Copyright (c) 2022 Triad National Security, LLC. All rights reserved.
# Copyright (c) 2022 Lawrence Livermore National Security, LLC. All rights
# reserved.
# Copyright (c) 2022 UT-Battelle, LLC. All rights reserved.
#
# Additional copyright and license information can be found in the LICENSE file
# distributed with this code, or at
# https://raw.githubusercontent.com/MPAS-Dev/MPAS-Analysis/main/LICENSE
"""
Regression tests for helpers in ``mpas_analysis.__main__``.
"""

import os
from unittest.mock import Mock, patch

from mpas_analysis.test import TestCase


# Importing mpas_analysis.__main__ triggers matplotlib imports in some test
# environments, so use a writable cache directory.
os.environ.setdefault('MPLCONFIGDIR', '/tmp/matplotlib')

import mpas_analysis.__main__ as main


class TestMain(TestCase):
def test_get_editable_install_dir_without_direct_url(self):
distribution = Mock()
distribution.read_text.return_value = None

with patch.object(main.Distribution, 'from_name',
return_value=distribution):
self.assertEqual(main.get_editable_install_dir('mpas_analysis'),
None)
Loading