[Zope-CVS] CVS: Packages/zpkgtools/zpkgtools/tests -
test_config.py:1.5 zpkg-error-1.conf:NONE zpkg-error-2.conf:NONE
Fred L. Drake, Jr.
fred at zope.com
Tue Mar 30 18:49:55 EST 2004
Update of /cvs-repository/Packages/zpkgtools/zpkgtools/tests
In directory cvs.zope.org:/tmp/cvs-serv29956/zpkgtools/tests
Modified Files:
test_config.py
Removed Files:
zpkg-error-1.conf zpkg-error-2.conf
Log Message:
- added Configuration.loadStream() to support loading from a stream,
to make it easier to embed test data in the unit tests
- moved some of the test data to strings
- added configuration option to control whether support code should be
included in the resulting package, and enough command-line support
to suppress the configuration
=== Packages/zpkgtools/zpkgtools/tests/test_config.py 1.4 => 1.5 ===
--- Packages/zpkgtools/zpkgtools/tests/test_config.py:1.4 Tue Mar 16 11:08:07 2004
+++ Packages/zpkgtools/zpkgtools/tests/test_config.py Tue Mar 30 18:49:54 2004
@@ -16,6 +16,8 @@
import os
import unittest
+from StringIO import StringIO
+
from zpkgtools import cfgparser
from zpkgtools import config
@@ -32,6 +34,12 @@
self.assert_(isinstance(path, basestring))
def test_constructor(self):
+ cf = config.Configuration()
+ self.assert_(cf.include_support_code)
+ self.assertEqual(len(cf.locations), 0)
+ self.assertEqual(len(cf.location_maps), 0)
+
+ def test_loadPath(self):
path = os.path.join(here, "zpkg-ok.conf")
cf = config.Configuration()
cf.loadPath(path)
@@ -42,22 +50,35 @@
def test_constructor_bad_config_setting(self):
# unknown option:
- path = os.path.join(here, "zpkg-error-1.conf")
- cf = config.Configuration()
self.assertRaises(cfgparser.ConfigurationError,
- cf.loadPath, path)
+ self.load_text, "unknown-option 42\n")
# repository-map without path
- path = os.path.join(here, "zpkg-error-2.conf")
- cf = config.Configuration()
self.assertRaises(cfgparser.ConfigurationError,
- cf.loadPath, path)
+ self.load_text, "resource-map \n")
+
+ # include-support-code too many times
+ self.assertRaises(cfgparser.ConfigurationError,
+ self.load_text, ("include-support-code false\n"
+ "include-support-code false\n"))
- def test_constructor_no_such_file(self):
+ def test_loadPath_no_such_file(self):
path = os.path.join(here, "no-such-file")
cf = config.Configuration()
self.assertRaises(IOError, cf.loadPath, path)
+ def load_text(self, text, path=None, basedir=None):
+ if path is None:
+ if basedir is None:
+ basedir = "foo"
+ path = os.path.join(basedir, "bar.conf")
+ if basedir is None:
+ os.path.dirname(path)
+ cf = config.Configuration()
+ sio = StringIO(text)
+ cf.loadStream(sio, path, basedir)
+ return cf
+
def test_suite():
return unittest.makeSuite(ConfigTestCase)
=== Removed File Packages/zpkgtools/zpkgtools/tests/zpkg-error-1.conf ===
=== Removed File Packages/zpkgtools/zpkgtools/tests/zpkg-error-2.conf ===
More information about the Zope-CVS
mailing list