[Python-checkins] python/nondist/sandbox/distutils_refactor/distutils/tests test_options.py, NONE, 1.1 test_dist.py, 1.1, 1.2 test_versionpredicate.py, 1.1, 1.2
anthonybaxter@users.sourceforge.net
anthonybaxter at users.sourceforge.net
Fri Jun 10 19:35:26 CEST 2005
Update of /cvsroot/python/python/nondist/sandbox/distutils_refactor/distutils/tests
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15190/tests
Modified Files:
test_dist.py test_versionpredicate.py
Added Files:
test_options.py
Log Message:
make tests runnable, add more options tests
--- NEW FILE: test_options.py ---
"""Tests for distutils.command.build_py."""
import os
import unittest
from distutils.core import Distribution
from distutils.tests import support
class OptionsParsingTestCase(support.LoggingSilencer,
unittest.TestCase):
def test_basic_options(self):
ae = self.assertEquals
d = Distribution()
ae(d.verbose, 1)
# Why doesn't Distribution have a default commands = [] ??
ae(hasattr(d, 'commands'), False)
d.script_name = 'test'
d.script_args = ['--quiet',
'build', '--force', '--build-temp=/tem/por/rary',
'install','--prefix=/foo/bar/baz']
d.parse_command_line()
ae(d.verbose, 0)
ae(d.commands, ['build','install',])
io = d.get_option_dict('install')
ae(io.keys(), ['prefix'])
ae(io['prefix'], ('command line', '/foo/bar/baz'))
bo = d.get_option_dict('build')
ae(sorted(bo.keys()), ['build_temp', 'force',])
ae(bo['force'], ('command line', 1))
ae(bo['build_temp'], ('command line', '/tem/por/rary'))
def test_aliases_and_negatives(self):
ae = self.assertEquals
d = Distribution()
ae(d.verbose, 1)
d.script_name = 'test'
d.script_args = ['--quiet', '--licence', 'install']
d.parse_command_line()
ae(d.verbose, 0)
d = Distribution()
ae(d.verbose, 1)
d.script_name = 'test'
d.script_args = ['--verbose', '--license', 'install']
d.parse_command_line()
ae(d.verbose, 2)
d = Distribution()
ae(d.verbose, 1)
d.script_name = 'test'
d.script_args = ['--verbose', '--verbose', '--verbose', 'install']
d.parse_command_line()
ae(d.verbose, 4)
def test_command_packages(self):
ae = self.assertEquals
d = Distribution()
d.script_name = 'test'
d.script_args = ['--command-packages=bar,baz', 'install']
d.parse_command_line()
ae(d.get_command_packages(), ['distutils.command', 'bar', 'baz'])
def test_suite():
return unittest.makeSuite(OptionsParsingTestCase)
if __name__ == "__main__":
unittest.main(defaultTest="test_suite")
Index: test_dist.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/distutils_refactor/distutils/tests/test_dist.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- test_dist.py 10 Jun 2005 06:43:22 -0000 1.1
+++ test_dist.py 10 Jun 2005 17:35:23 -0000 1.2
@@ -67,6 +67,9 @@
self.assertEqual(d.get_command_packages(),
["distutils.command", "foo.bar", "distutils.tests"])
cmd = d.get_command_obj("test_dist")
+ # Nasty. If this is run directly, test_dist is __main__.test_dist
+ if __name__ == "__main__":
+ from distutils.tests.test_dist import test_dist
self.assert_(isinstance(cmd, test_dist))
self.assertEqual(cmd.sample_option, "sometext")
@@ -187,3 +190,7 @@
suite.addTest(unittest.makeSuite(DistributionTestCase))
suite.addTest(unittest.makeSuite(MetadataTestCase))
return suite
+
+if __name__ == "__main__":
+ unittest.main(defaultTest="test_suite")
+
Index: test_versionpredicate.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/distutils_refactor/distutils/tests/test_versionpredicate.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- test_versionpredicate.py 10 Jun 2005 06:43:22 -0000 1.1
+++ test_versionpredicate.py 10 Jun 2005 17:35:24 -0000 1.2
@@ -7,3 +7,7 @@
def test_suite():
return doctest.DocTestSuite(distutils.versionpredicate)
+
+if __name__ == "__main__":
+ unittest.main(defaultTest="test_suite")
+
More information about the Python-checkins
mailing list