File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 :
Original file line number Diff line number Diff line change 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 )
You can’t perform that action at this time.
0 commit comments