Coverage for tests / test_run_by_scons.py: 32%
21 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-17 08:38 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-17 08:38 +0000
1# This file is part of sconsUtils.
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/>.
22"""
23Very simple tests to show that the test running
24infrastructure can run more than one test file.
25There is nothing scons-specific about these tests
26but they must be run with scons running pytest and
27not by simply running pytest.
28"""
30import os
31import unittest
34class SimplestPossibleTestCase(unittest.TestCase):
35 """Tests that don't rely on any external code."""
37 def testSimple(self):
38 self.assertEqual(2 + 2, 4)
40 def testEnvironment(self):
41 """Test the environment. The test will fail if the tests are run
42 by anything other than SCons."""
43 envVar = "XDG_CACHE_HOME"
44 self.assertIn(envVar, os.environ)
45 self.assertTrue(os.path.exists(os.environ[envVar]), f"Check path {os.environ[envVar]}")
47 def testNoImplicitMultithreading(self):
48 """Test that the environment has turned off implicit
49 multithreading.
50 """
51 envVar = "OMP_NUM_THREADS"
52 self.assertIn(envVar, os.environ)
53 self.assertEqual(os.environ[envVar], "1")
55 try:
56 import numexpr
57 except ImportError:
58 numexpr = None
60 if numexpr:
61 self.assertEqual(numexpr.utils.get_num_threads(), 1)
64if __name__ == "__main__": 64 ↛ 65line 64 didn't jump to line 65 because the condition on line 64 was never true
65 unittest.main()