summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2013-02-20 08:45:44 -0500
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2013-02-20 08:45:44 -0500
commite17e41dcff096ead7e129a0db063f75de44aaa2b (patch)
tree5298825c42d3290c6e2eaeba103c1fb2836e8aa7
parentbe0de88922a58504c655361970378375426b5acc (diff)
downloadbcfg2-e17e41dcff096ead7e129a0db063f75de44aaa2b.tar.gz
bcfg2-e17e41dcff096ead7e129a0db063f75de44aaa2b.tar.bz2
bcfg2-e17e41dcff096ead7e129a0db063f75de44aaa2b.zip
fixed unit tests using long ints for py3k
-rw-r--r--doc/development/compat.txt2
-rw-r--r--src/lib/Bcfg2/Compat.py7
-rw-r--r--testsuite/Testsrc/Testlib/TestClient/TestTools/Test_init.py13
3 files changed, 16 insertions, 6 deletions
diff --git a/doc/development/compat.txt b/doc/development/compat.txt
index b7bf87bec..90df45676 100644
--- a/doc/development/compat.txt
+++ b/doc/development/compat.txt
@@ -98,6 +98,8 @@ behavior (e.g., :func:`input`) do not cause unexpected side-effects.
+---------------------------------+--------------------------------------------------+---------------------------------------------------------+
| reduce | :func:`reduce` | :func:`functools.reduce` |
+---------------------------------+--------------------------------------------------+---------------------------------------------------------+
+| long | :func:`long` | :func:`int` |
++---------------------------------+--------------------------------------------------+---------------------------------------------------------+
Python 2.4 compatibility
------------------------
diff --git a/src/lib/Bcfg2/Compat.py b/src/lib/Bcfg2/Compat.py
index b0f0ef5cf..beb534791 100644
--- a/src/lib/Bcfg2/Compat.py
+++ b/src/lib/Bcfg2/Compat.py
@@ -260,3 +260,10 @@ def oct_mode(mode):
:type mode: int
:returns: string """
return oct(mode).replace('o', '')
+
+
+try:
+ long = long
+except NameError:
+ # longs are just ints in py3k
+ long = int
diff --git a/testsuite/Testsrc/Testlib/TestClient/TestTools/Test_init.py b/testsuite/Testsrc/Testlib/TestClient/TestTools/Test_init.py
index 355fec494..19f76f2f1 100644
--- a/testsuite/Testsrc/Testlib/TestClient/TestTools/Test_init.py
+++ b/testsuite/Testsrc/Testlib/TestClient/TestTools/Test_init.py
@@ -1,9 +1,8 @@
import os
import sys
-import copy
import lxml.etree
-import subprocess
from mock import Mock, MagicMock, patch
+from Bcfg2.Compat import long
from Bcfg2.Client.Tools import Tool, SvcTool, PkgTool, \
ToolInstantiationError
@@ -82,16 +81,18 @@ class TestTool(Bcfg2TestCase):
@patch("os.stat")
def inner(mock_stat):
- mock_stat.return_value = (33261, 2245040, 64770L, 1, 0, 0, 25552,
- 1360831382, 1352194410, 1354626626)
+ mock_stat.return_value = (33261, 2245040, long(64770), 1, 0, 0,
+ 25552, 1360831382, 1352194410,
+ 1354626626)
t._check_execs()
self.assertItemsEqual(mock_stat.call_args_list,
[call(e) for e in t.__execs__])
# not executable
mock_stat.reset_mock()
- mock_stat.return_value = (33188, 2245040, 64770L, 1, 0, 0, 25552,
- 1360831382, 1352194410, 1354626626)
+ mock_stat.return_value = (33188, 2245040, long(64770), 1, 0, 0,
+ 25552, 1360831382, 1352194410,
+ 1354626626)
self.assertRaises(ToolInstantiationError, t._check_execs)
# non-existant