Coverage for tests/test_bps_utils.py: 54%
Shortcuts on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# This file is part of ctrl_bps.
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/>.
21import os
22import shutil
23import tempfile
24import unittest
26from lsst.ctrl.bps.bps_utils import chdir
29TESTDIR = os.path.abspath(os.path.dirname(__file__))
32class TestChdir(unittest.TestCase):
34 def setUp(self):
35 self.cwd = os.getcwd()
36 self.tmpdir = tempfile.mkdtemp(dir=TESTDIR)
38 def tearDown(self):
39 shutil.rmtree(self.tmpdir, ignore_errors=True)
41 def testSuccessfulChdir(self):
42 self.assertNotEqual(os.getcwd(), self.tmpdir)
43 with chdir(self.tmpdir):
44 self.assertEqual(os.getcwd(), self.tmpdir)
45 self.assertNotEqual(os.getcwd(), self.tmpdir)
47 def testFailingChdir(self):
48 dir_not_there = os.path.join(self.tmpdir, "notthere")
49 with self.assertRaises(FileNotFoundError):
50 with chdir(dir_not_there):
51 pass # should not get here
54if __name__ == "__main__": 54 ↛ 55line 54 didn't jump to line 55, because the condition on line 54 was never true
55 unittest.main()