[Zodb-checkins] CVS: Packages/ZConfig/tests - test_datatypes.py:1.1.2.5
Fred L. Drake, Jr.
fred@zope.com
Tue, 24 Dec 2002 22:54:27 -0500
Update of /cvs-repository/Packages/ZConfig/tests
In directory cvs.zope.org:/tmp/cvs-serv1828/tests
Modified Files:
Tag: zconfig-schema-devel-branch
test_datatypes.py
Log Message:
Modify the socket-address data type to raise ValueError when the value
corresponds to an AF_UNIX address on Windows. Not really sure this is the
right thing, but avoids looking for socket.AF_UNIX when it doesn't exist.
=== Packages/ZConfig/tests/test_datatypes.py 1.1.2.4 => 1.1.2.5 ===
--- Packages/ZConfig/tests/test_datatypes.py:1.1.2.4 Sat Dec 21 23:18:46 2002
+++ Packages/ZConfig/tests/test_datatypes.py Tue Dec 24 22:54:26 2002
@@ -13,12 +13,12 @@
##############################################################################
"""Tests of standard ZConfig datatypes."""
-import sys
import os
+import socket
+import sys
+import tempfile
import unittest
-from socket import AF_INET, AF_UNIX
-
import ZConfig.datatypes
try:
@@ -159,12 +159,20 @@
def test_datatype_socket_address(self):
convert = self.types.get("socket-address")
eq = self.assertEqual
+ raises = self.assertRaises
+ AF_INET = socket.AF_INET
eq(convert("Host.Example.Com:80"),(AF_INET, ("host.example.com", 80)))
eq(convert(":80"), (AF_INET, ("", 80)))
eq(convert("80"), (AF_INET, ("", 80)))
eq(convert("host.EXAMPLE.com"), (AF_INET, ("host.example.com",None)))
- eq(convert("/tmp/var/@345.4"), (AF_UNIX, "/tmp/var/@345.4"))
- eq(convert("/tmp/var/@345.4:80"), (AF_UNIX, "/tmp/var/@345.4:80"))
+ if hasattr(socket, "AF_UNIX"):
+ eq(convert("/tmp/var/@345.4"),
+ (AF_UNIX, "/tmp/var/@345.4"))
+ eq(convert("/tmp/var/@345.4:80"),
+ (AF_UNIX, "/tmp/var/@345.4:80"))
+ else:
+ raises(ValueError, convert, "/tmp/var/@345.4")
+ raises(ValueError, convert, "/tmp/var/@345.4:80")
def test_constructor(self):
convert = self.types.get('constructor')
@@ -198,7 +206,7 @@
raises = self.assertRaises
eq(convert('.'), '.')
eq(convert(os.path.dirname(here)), os.path.dirname(here))
- raises(ValueError, convert, '/a/hopefully/non/existent/path')
+ raises(ValueError, convert, tempfile.mktemp())
def test_existing_file(self):
convert = self.types.get('existing-file')
@@ -206,7 +214,7 @@
raises = self.assertRaises
eq(convert('.'), '.')
eq(convert(here), here)
- raises(ValueError, convert, '/a/hopefully/non/existent/path')
+ raises(ValueError, convert, tempfile.mktemp())
def test_existing_path(self):
convert = self.types.get('existing-path')
@@ -215,7 +223,7 @@
eq(convert('.'), '.')
eq(convert(here), here)
eq(convert(os.path.dirname(here)), os.path.dirname(here))
- raises(ValueError, convert, '/a/hopefully/non/existent/path')
+ raises(ValueError, convert, tempfile.mktemp())
def test_existing_dirpath(self):
convert = self.types.get('existing-dirpath')
@@ -223,7 +231,7 @@
raises = self.assertRaises
eq(convert('.'), '.')
eq(convert(here), here)
- raises(ValueError, convert, '/a/hopefully/non/existent/path')
+ raises(ValueError, convert, '/a/hopefully/nonexistent/path')
raises(ValueError, convert, here + '/bogus')
def test_space_sep_key_value(self):