Put the Copyright years in by script, not by hand.
[scons.git] / src / engine / SCons / Node / AliasTests.py
1 #
2 # __COPYRIGHT__
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
29 import SCons.Errors
30 import SCons.Node.Alias
31
32 class AliasTestCase(unittest.TestCase):
33
34     def test_AliasNameSpace(self):
35         """Test creating an Alias name space
36         """
37         ans = SCons.Node.Alias.AliasNameSpace()
38         assert not ans is None, ans
39
40     def test_ANS_Alias(self):
41         """Test the Alias() factory
42         """
43         ans = SCons.Node.Alias.AliasNameSpace()
44
45         a = ans.Alias('a1')
46         assert a.name == 'a1', a.name
47
48         try:
49             ans.Alias('a1')
50         except SCons.Errors.UserError:
51             pass
52         else:
53             raise TestFailed, "did not catch expected UserError"
54
55     def test_lookup(self):
56         """Test the lookup() method
57         """
58         ans = SCons.Node.Alias.AliasNameSpace()
59
60         ans.Alias('a1')
61         a = ans.lookup('a1')
62         assert a.name == 'a1', a.name
63
64         a1 = ans.lookup('a1')
65         assert a is a1, a1
66
67         a = ans.lookup('a2')
68         assert a == None, a
69
70     def test_Alias(self):
71         """Test creating an Alias() object
72         """
73         a1 = SCons.Node.Alias.Alias('a')
74         assert a1.name == 'a', a1.name
75
76         a2 = SCons.Node.Alias.Alias('a')
77         assert a2.name == 'a', a2.name
78
79         assert not a1 is a2
80         assert a1.name == a2.name
81
82
83
84 if __name__ == "__main__":
85     suite = unittest.makeSuite(AliasTestCase, 'test_')
86     if not unittest.TextTestRunner().run(suite).wasSuccessful():
87         sys.exit(1)