# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+import os
+import tempfile
import testtools
+import unittest
from buildfarm import util
-class DhmTimeTests(testtools.TestCase):
+class DhmTimeTests(unittest.TestCase):
def test_simple(self):
self.assertEquals("0s", util.dhm_time(0))
self.assertEquals("-", util.dhm_time(-20))
self.assertEquals("1d 3h 1m", util.dhm_time(97265))
self.assertEquals("3h 1m", util.dhm_time(10865))
+
+
+class LoadTests(testtools.TestCase):
+
+ def test_simple(self):
+ fd, name = tempfile.mkstemp()
+ self.addCleanup(os.remove, name)
+ f = os.fdopen(fd, 'w')
+ f.write("""one
+two
+three\r
+
+for
+""")
+ f.close()
+ l = util.load_list(name)
+ self.assertEquals(4, len(l))
+ self.assertEquals("three", l[2])
+
+
return ret
+def FileLoad(filename):
+ """read a file into a string"""
+ f = open(filename, 'r')
+ try:
+ return f.read()
+ finally:
+ f.close()
+
+
def dhm_time(sec):
"""display a time as days, hours, minutes"""
days = int(sec / (60*60*24));