]>
git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Python/Python-2.7.2/Lib/distutils/tests/test_dep_util.py
1 """Tests for distutils.dep_util."""
6 from distutils
.dep_util
import newer
, newer_pairwise
, newer_group
7 from distutils
.errors
import DistutilsFileError
8 from distutils
.tests
import support
9 from test
.test_support
import run_unittest
11 class DepUtilTestCase(support
.TempdirManager
, unittest
.TestCase
):
15 tmpdir
= self
.mkdtemp()
16 new_file
= os
.path
.join(tmpdir
, 'new')
17 old_file
= os
.path
.abspath(__file__
)
19 # Raise DistutilsFileError if 'new_file' does not exist.
20 self
.assertRaises(DistutilsFileError
, newer
, new_file
, old_file
)
22 # Return true if 'new_file' exists and is more recently modified than
23 # 'old_file', or if 'new_file' exists and 'old_file' doesn't.
24 self
.write_file(new_file
)
25 self
.assertTrue(newer(new_file
, 'I_dont_exist'))
26 self
.assertTrue(newer(new_file
, old_file
))
28 # Return false if both exist and 'old_file' is the same age or younger
30 self
.assertFalse(newer(old_file
, new_file
))
32 def test_newer_pairwise(self
):
33 tmpdir
= self
.mkdtemp()
34 sources
= os
.path
.join(tmpdir
, 'sources')
35 targets
= os
.path
.join(tmpdir
, 'targets')
38 one
= os
.path
.join(sources
, 'one')
39 two
= os
.path
.join(sources
, 'two')
40 three
= os
.path
.abspath(__file__
) # I am the old file
41 four
= os
.path
.join(targets
, 'four')
46 self
.assertEqual(newer_pairwise([one
, two
], [three
, four
]),
49 def test_newer_group(self
):
50 tmpdir
= self
.mkdtemp()
51 sources
= os
.path
.join(tmpdir
, 'sources')
53 one
= os
.path
.join(sources
, 'one')
54 two
= os
.path
.join(sources
, 'two')
55 three
= os
.path
.join(sources
, 'three')
56 old_file
= os
.path
.abspath(__file__
)
58 # return true if 'old_file' is out-of-date with respect to any file
59 # listed in 'sources'.
62 self
.write_file(three
)
63 self
.assertTrue(newer_group([one
, two
, three
], old_file
))
64 self
.assertFalse(newer_group([one
, two
, old_file
], three
))
68 self
.assertRaises(OSError, newer_group
, [one
, two
, old_file
], three
)
70 self
.assertFalse(newer_group([one
, two
, old_file
], three
,
73 self
.assertTrue(newer_group([one
, two
, old_file
], three
,
78 return unittest
.makeSuite(DepUtilTestCase
)
80 if __name__
== "__main__":
81 run_unittest(test_suite())