diff options
author | Tarek Ziade <tarek@ziade.org> | 2011-05-19 11:07:25 (GMT) |
---|---|---|
committer | Tarek Ziade <tarek@ziade.org> | 2011-05-19 11:07:25 (GMT) |
commit | 1231a4e097e55c5ac793ddaedad23bfd610591e6 (patch) | |
tree | d473428e1161a617cd8949c365f5e08c85224bda /Lib/packaging/tests/test_manifest.py | |
parent | 566f8a646e937c17ff5bc7a8abc7af3c332b66ec (diff) | |
download | cpython-1231a4e097e55c5ac793ddaedad23bfd610591e6.zip cpython-1231a4e097e55c5ac793ddaedad23bfd610591e6.tar.gz cpython-1231a4e097e55c5ac793ddaedad23bfd610591e6.tar.bz2 |
initial import of the packaging package in the standard library
Diffstat (limited to 'Lib/packaging/tests/test_manifest.py')
-rw-r--r-- | Lib/packaging/tests/test_manifest.py | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/Lib/packaging/tests/test_manifest.py b/Lib/packaging/tests/test_manifest.py new file mode 100644 index 0000000..21a42c3 --- /dev/null +++ b/Lib/packaging/tests/test_manifest.py @@ -0,0 +1,72 @@ +"""Tests for packaging.manifest.""" +import os +import logging +from io import StringIO +from packaging.manifest import Manifest + +from packaging.tests import unittest, support + +_MANIFEST = """\ +recursive-include foo *.py # ok +# nothing here + +# + +recursive-include bar \\ + *.dat *.txt +""" + +_MANIFEST2 = """\ +README +file1 +""" + + +class ManifestTestCase(support.TempdirManager, + support.LoggingCatcher, + unittest.TestCase): + + def test_manifest_reader(self): + tmpdir = self.mkdtemp() + MANIFEST = os.path.join(tmpdir, 'MANIFEST.in') + with open(MANIFEST, 'w') as f: + f.write(_MANIFEST) + + manifest = Manifest() + manifest.read_template(MANIFEST) + + warnings = self.get_logs(logging.WARNING) + # the manifest should have been read and 3 warnings issued + # (we didn't provide the files) + self.assertEqual(3, len(warnings)) + for warning in warnings: + self.assertIn('no files found matching', warning) + + # reset logs for the next assert + self.loghandler.flush() + + # manifest also accepts file-like objects + with open(MANIFEST) as f: + manifest.read_template(f) + + # the manifest should have been read and 3 warnings issued + # (we didn't provide the files) + self.assertEqual(3, len(warnings)) + + def test_default_actions(self): + tmpdir = self.mkdtemp() + self.addCleanup(os.chdir, os.getcwd()) + os.chdir(tmpdir) + self.write_file('README', 'xxx') + self.write_file('file1', 'xxx') + content = StringIO(_MANIFEST2) + manifest = Manifest() + manifest.read_template(content) + self.assertEqual(['README', 'file1'], manifest.files) + + +def test_suite(): + return unittest.makeSuite(ManifestTestCase) + +if __name__ == '__main__': + unittest.main(defaultTest='test_suite') |