[cedar-backup-svn] SF.net SVN: cedar-backup: [845] cedar-backup2/trunk
Brought to you by:
pronovic
|
From: <pro...@us...> - 2008-02-07 15:21:42
|
Revision: 845
http://cedar-backup.svn.sourceforge.net/cedar-backup/?rev=845&view=rev
Author: pronovic
Date: 2008-02-07 07:21:36 -0800 (Thu, 07 Feb 2008)
Log Message:
-----------
Fix SF bug #1861878
Modified Paths:
--------------
cedar-backup2/trunk/CedarBackup2/testutil.py
cedar-backup2/trunk/Changelog
cedar-backup2/trunk/test/configtests.py
cedar-backup2/trunk/test/splittests.py
Modified: cedar-backup2/trunk/CedarBackup2/testutil.py
===================================================================
--- cedar-backup2/trunk/CedarBackup2/testutil.py 2008-02-07 15:21:17 UTC (rev 844)
+++ cedar-backup2/trunk/CedarBackup2/testutil.py 2008-02-07 15:21:36 UTC (rev 845)
@@ -8,7 +8,7 @@
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
-# Copyright (c) 2004-2006 Kenneth J. Pronovici.
+# Copyright (c) 2004-2006,2008 Kenneth J. Pronovici.
# All rights reserved.
#
# This program is free software; you can redistribute it and/or
@@ -482,3 +482,28 @@
locales.append(line.rstrip())
return locales
+
+####################################
+# hexFloatLiteralAllowed() function
+####################################
+
+def hexFloatLiteralAllowed():
+ """
+ Indicates whether hex float literals are allowed by the interpreter.
+
+ As far back as 2004, some Python documentation indicated that octal and hex
+ notation applies only to integer literals. However, prior to Python 2.5, it
+ was legal to construct a float with an argument like 0xAC. This check
+ provides a version-based indication of whether the current interpreter
+ supports that behavior.
+
+ This check exists so that unit tests can continue to test the same thing as
+ always for pre-2.5 interpreters (i.e. making sure backwards compatibility
+ doesn't break) while still continuing to work for later interpreters.
+
+ The returned value is True for Python <= 2.5, and False otherwise.
+ """
+ if map(int, [sys.version_info[0], sys.version_info[1]]) < [2, 5]:
+ return True
+ return False
+
Modified: cedar-backup2/trunk/Changelog
===================================================================
--- cedar-backup2/trunk/Changelog 2008-02-07 15:21:17 UTC (rev 844)
+++ cedar-backup2/trunk/Changelog 2008-02-07 15:21:36 UTC (rev 845)
@@ -1,3 +1,14 @@
+Version 2.15.2 07 Feb 2007
+
+ * Fix two unit test failures when using Python 2.5 (SF #1861878).
+ - Add new function testtutil.hexFloatLiteralAllowed()
+ - Fix splittests.TestByteQuantity.testConstructor_004() for 0xAC
+ - Fix configtests.TestBlankBehavior.testConstructor_006() for 0xAC
+ - Octal and hex notations apply only to integer literals. However,
+ Python apparently didn't enforce this before 2.5. These tests
+ actually did their job, which was to make me aware of the change.
+ This was a test-only bug, and there was no functional impact.
+
Version 2.15.1 19 Dec 2007
* Improve error reporting for managed client action failures.
Modified: cedar-backup2/trunk/test/configtests.py
===================================================================
--- cedar-backup2/trunk/test/configtests.py 2008-02-07 15:21:17 UTC (rev 844)
+++ cedar-backup2/trunk/test/configtests.py 2008-02-07 15:21:36 UTC (rev 845)
@@ -9,7 +9,7 @@
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
-# Copyright (c) 2004-2007 Kenneth J. Pronovici.
+# Copyright (c) 2004-2008 Kenneth J. Pronovici.
# All rights reserved.
#
# This program is free software; you can redistribute it and/or
@@ -102,6 +102,7 @@
import os
import unittest
from CedarBackup2.testutil import findResources, removedir, failUnlessAssignRaises
+from CedarBackup2.testutil import hexFloatLiteralAllowed
from CedarBackup2.config import ActionHook, PreActionHook, PostActionHook, CommandOverride
from CedarBackup2.config import ExtendedAction, ActionDependencies, BlankBehavior
from CedarBackup2.config import CollectFile, CollectDir, PurgeDir, LocalPeer, RemotePeer
@@ -1084,8 +1085,10 @@
self.failUnlessEqual("1E6", behavior.blankFactor)
behavior.blankFactor = "0.25E2"
self.failUnlessEqual("0.25E2", behavior.blankFactor)
- behavior.blankFactor = "0xAC"
- self.failUnlessEqual("0xAC", behavior.blankFactor)
+ if hexFloatLiteralAllowed():
+ # Some interpreters allow this, some don't
+ behavior.blankFactor = "0xAC"
+ self.failUnlessEqual("0xAC", behavior.blankFactor)
def testConstructor_007(self):
"""
Modified: cedar-backup2/trunk/test/splittests.py
===================================================================
--- cedar-backup2/trunk/test/splittests.py 2008-02-07 15:21:17 UTC (rev 844)
+++ cedar-backup2/trunk/test/splittests.py 2008-02-07 15:21:36 UTC (rev 845)
@@ -9,7 +9,7 @@
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
-# Copyright (c) 2007 Kenneth J. Pronovici.
+# Copyright (c) 2007-2008 Kenneth J. Pronovici.
# All rights reserved.
#
# This program is free software; you can redistribute it and/or
@@ -111,6 +111,7 @@
from CedarBackup2.util import UNIT_BYTES, UNIT_KBYTES, UNIT_MBYTES, UNIT_GBYTES
from CedarBackup2.testutil import findResources, buildPath, removedir, extractTar
from CedarBackup2.testutil import failUnlessAssignRaises, platformSupportsLinks, availableLocales
+from CedarBackup2.testutil import hexFloatLiteralAllowed
from CedarBackup2.xmlutil import createOutputDom, serializeDom
from CedarBackup2.extend.split import LocalConfig, SplitConfig, ByteQuantity
from CedarBackup2.extend.split import _splitFile, _splitDailyDir
@@ -221,8 +222,10 @@
self.failUnlessEqual("1E6", quantity.quantity)
quantity.quantity = "0.25E2"
self.failUnlessEqual("0.25E2", quantity.quantity)
- quantity.quantity = "0xAC"
- self.failUnlessEqual("0xAC", quantity.quantity)
+ if hexFloatLiteralAllowed():
+ # Some interpreters allow this, some don't
+ quantity.quantity = "0xAC"
+ self.failUnlessEqual("0xAC", quantity.quantity)
def testConstructor_005(self):
"""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|