Add the Library() method.
[scons.git] / src / engine / SCons / UtilTests.py
1 #
2 # Copyright (c) 2001 Steven Knight
3 #
4 # Permission is hereby granted, free of charge, to any person obtaining
5 # a copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish,
8 # distribute, sublicense, and/or sell copies of the Software, and to
9 # permit persons to whom the Software is furnished to do so, subject to
10 # the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
16 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
17 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 #
23
24 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
25
26 import sys
27 import unittest
28 import SCons.Node
29 import SCons.Node.FS
30 from SCons.Util import scons_str2nodes
31
32 class UtilTestCase(unittest.TestCase):
33     def test_str2nodes(self):
34         """Test the str2nodes function."""
35         nodes = scons_str2nodes("Util.py UtilTests.py")
36         assert len(nodes) == 2
37         assert isinstance(nodes[0], SCons.Node.FS.File)
38         assert isinstance(nodes[1], SCons.Node.FS.File)
39         assert nodes[0].path == "Util.py"
40         assert nodes[1].path == "UtilTests.py"
41
42         nodes = scons_str2nodes("Util.py UtilTests.py", SCons.Node.FS.FS().File)
43         assert len(nodes) == 2
44         assert isinstance(nodes[0], SCons.Node.FS.File)
45         assert isinstance(nodes[1], SCons.Node.FS.File)
46         assert nodes[0].path == "Util.py"
47         assert nodes[1].path == "UtilTests.py"
48
49         nodes = scons_str2nodes(["Util.py", "UtilTests.py"])
50         assert len(nodes) == 2
51         assert isinstance(nodes[0], SCons.Node.FS.File)
52         assert isinstance(nodes[1], SCons.Node.FS.File)
53         assert nodes[0].path == "Util.py"
54         assert nodes[1].path == "UtilTests.py"
55
56         n1 = SCons.Node.FS.default_fs.File("Util.py")
57         nodes = scons_str2nodes([n1, "UtilTests.py"])
58         assert len(nodes) == 2
59         assert isinstance(nodes[0], SCons.Node.FS.File)
60         assert isinstance(nodes[1], SCons.Node.FS.File)
61         assert nodes[0].path == "Util.py"
62         assert nodes[1].path == "UtilTests.py"
63
64         class SConsNode(SCons.Node.Node):
65             pass
66         node = scons_str2nodes(SConsNode())
67
68         class OtherNode:
69             pass
70         node = scons_str2nodes(OtherNode())
71
72 if __name__ == "__main__":
73     suite = unittest.makeSuite(UtilTestCase, 'test_')
74     if not unittest.TextTestRunner().run(suite).wasSuccessful():
75         sys.exit(1)