Coverage for tests/test_getPackageDir.py: 59%

18 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-07-25 09:27 +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# Use of this source code is governed by a 3-clause BSD-style 

10# license that can be found in the LICENSE file. 

11 

12import os 

13import sys 

14import unittest 

15 

16import lsst.utils.tests 

17from lsst.utils import getPackageDir 

18 

19 

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

21class GetPackageDirTestCase(unittest.TestCase): 

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

23 

24 def testBasics(self): 

25 utilsPath = getPackageDir("utils") 

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

27 

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

29 with self.assertRaises(LookupError): 

30 getPackageDir("nameOfNonexistendPackage2234q?#!") 

31 

32 def testUnicodeBasics(self): 

33 utilsPath = getPackageDir("utils") 

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

35 

36 

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

38 """Test for file descriptor leaks.""" 

39 

40 

41def setup_module(module): 

42 """Initialize the pytest environment.""" 

43 lsst.utils.tests.init() 

44 

45 

46if __name__ == "__main__": 

47 setup_module(sys.modules[__name__]) 

48 unittest.main()