Coverage for tests/test_simple.py: 32%
21 statements
« prev ^ index » next coverage.py v7.4.1, created at 2024-02-07 11:22 +0000
« prev ^ index » next coverage.py v7.4.1, created at 2024-02-07 11:22 +0000
1"""
2Very simple tests to show that the test running
3infrastructure can run more than one test file.
4There is nothing scons-specific about these tests.
5"""
7import os
8import unittest
11class SimplestPossibleTestCase(unittest.TestCase):
12 """Tests that don't rely on any external code."""
14 def testSimple(self):
15 self.assertEqual(2 + 2, 4)
17 def testEnvironment(self):
18 """Test the environment. The test will fail if the tests are run
19 by anything other than SCons."""
20 envVar = "XDG_CACHE_HOME"
21 self.assertIn(envVar, os.environ)
22 self.assertTrue(os.path.exists(os.environ[envVar]), f"Check path {os.environ[envVar]}")
24 def testNoImplicitMultithreading(self):
25 """Test that the environment has turned off implicit
26 multithreading.
27 """
28 envVar = "OMP_NUM_THREADS"
29 self.assertIn(envVar, os.environ)
30 self.assertEqual(os.environ[envVar], "1")
32 try:
33 import numexpr
34 except ImportError:
35 numexpr = None
37 if numexpr:
38 self.assertEqual(numexpr.utils.get_num_threads(), 1)
41if __name__ == "__main__": 41 ↛ 42line 41 didn't jump to line 42, because the condition on line 41 was never true
42 unittest.main()