[Zope3-checkins] CVS: Zope3/src/zope/app/applicationcontrol/tests - test_runtimeinfo.py:1.8

Dmitry Vasiliev dima at hlabs.spb.ru
Tue Mar 23 08:35:10 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/applicationcontrol/tests
In directory cvs.zope.org:/tmp/cvs-serv5236/tests

Modified Files:
	test_runtimeinfo.py 
Log Message:
RuntimeInfo changes:
- new method: getPreferredEncoding()
- getSystemPlatform(), getPythonVersion() now returns an unicode strings encoded
  with the preferred system encoding


=== Zope3/src/zope/app/applicationcontrol/tests/test_runtimeinfo.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/applicationcontrol/tests/test_runtimeinfo.py:1.7	Sat Mar 13 10:21:07 2004
+++ Zope3/src/zope/app/applicationcontrol/tests/test_runtimeinfo.py	Tue Mar 23 08:35:09 2004
@@ -17,6 +17,11 @@
 import unittest
 import os, sys, time
 
+try:
+    import locale
+except ImportError:
+    locale = None
+
 from zope.component import getService
 from zope.interface import implements
 from zope.interface.verify import verifyObject
@@ -42,9 +47,19 @@
         from zope.app.applicationcontrol.runtimeinfo import RuntimeInfo
         return RuntimeInfo(applicationController)
 
+    def _getPreferredEncoding(self):
+        if locale is None:
+            return "Latin1"
+        return locale.getpreferredencoding()
+
     def testIRuntimeInfoVerify(self):
         verifyObject(IRuntimeInfo, self._Test__new())
 
+    def test_PreferredEncoding(self):
+        runtime_info = self._Test__new()
+        enc = self._getPreferredEncoding()
+        self.assertEqual(runtime_info.getPreferredEncoding(), enc)
+
     def test_ZopeVersion(self):
         runtime_info = self._Test__new()
 
@@ -57,18 +72,22 @@
                                          stupid_version_string)
     def test_PythonVersion(self):
         runtime_info = self._Test__new()
-        self.assertEqual(runtime_info.getPythonVersion(), sys.version)
+        enc = self._getPreferredEncoding()
+        self.assertEqual(runtime_info.getPythonVersion(),
+                unicode(sys.version, enc))
 
     def test_SystemPlatform(self):
         runtime_info = self._Test__new()
         test_platform = (sys.platform,)
         if hasattr(os, "uname"):
             test_platform = os.uname()
-        self.assertEqual(runtime_info.getSystemPlatform(), test_platform)
+        enc = self._getPreferredEncoding()
+        self.assertEqual(runtime_info.getSystemPlatform(),
+                unicode(" ".join(test_platform), enc))
 
     def test_CommandLine(self):
         runtime_info = self._Test__new()
-        self.assertEqual(runtime_info.getCommandLine(), sys.argv)
+        self.assertEqual(runtime_info.getCommandLine(), " ".join(sys.argv))
 
     def test_ProcessId(self):
         runtime_info = self._Test__new()




More information about the Zope3-Checkins mailing list