Coverage for tests/test_getPackageDir.py: 59%

18 statements  

« prev     ^ index     » next       coverage.py v7.4.0, created at 2024-01-19 11:15 +0000

1# This file is part of utils. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (https://www.lsst.org). 

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

9# This program is free software: you can redistribute it and/or modify 

10# it under the terms of the GNU General Public License as published by 

11# the Free Software Foundation, either version 3 of the License, or 

12# (at your option) any later version. 

13# 

14# This program is distributed in the hope that it will be useful, 

15# but WITHOUT ANY WARRANTY; without even the implied warranty of 

16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

17# GNU General Public License for more details. 

18# 

19# You should have received a copy of the GNU General Public License 

20# along with this program. If not, see <https://www.gnu.org/licenses/>. 

21 

22import os 

23import sys 

24import unittest 

25 

26import lsst.utils.tests 

27from lsst.utils import getPackageDir 

28 

29 

30@unittest.skipIf("UTILS_DIR" not in os.environ, "EUPS has not set up this package.") 

31class GetPackageDirTestCase(unittest.TestCase): 

32 """Test that EUPS environment variables can be read.""" 

33 

34 def testBasics(self): 

35 utilsPath = getPackageDir("utils") 

36 self.assertTrue(os.path.isfile(os.path.join(utilsPath, "tests", "test_getPackageDir.py"))) 

37 

38 # Confirm that we have a correct Python exception and pex exception 

39 with self.assertRaises(LookupError): 

40 getPackageDir("nameOfNonexistendPackage2234q?#!") 

41 

42 def testUnicodeBasics(self): 

43 utilsPath = getPackageDir("utils") 

44 self.assertTrue(os.path.isfile(os.path.join(utilsPath, "tests", "test_getPackageDir.py"))) 

45 

46 

47class TestMemory(lsst.utils.tests.MemoryTestCase): 

48 """Test for file descriptor leaks.""" 

49 

50 

51def setup_module(module): 

52 """Initialize the pytest environment.""" 

53 lsst.utils.tests.init() 

54 

55 

56if __name__ == "__main__": 

57 setup_module(sys.modules[__name__]) 

58 unittest.main()