Tests classes and functions in text_helpers
-Should be able run from python2 and python3!
+.. todo:: test that no color codes are printed if stdout is not a terminal
For help see :py:mod:`unittest`
"""
expect = tuple(range(20)) + tuple(range(80,100))
self.assertEqual(short, expect)
- # todo: test that no color codes are printed if stdout is not a terminal
+ def test_size_str(self):
+ """Test function size_str"""
+ self.assertEqual(size_str(12), '12 B')
+ self.assertEqual(size_str(1023), '1023 B')
+ self.assertEqual(size_str(1024), '1024 B')
+ self.assertEqual(size_str(1025), '1.0 kB')
+ self.assertEqual(size_str(2.3456 * 1024), '2.3 kB')
+ self.assertEqual(size_str(3.4567 * 1024 * 1024), '3.5 MB')
+ self.assertEqual(size_str(4.5678 * 1024 * 1024 * 1024), '4.6 GB')
+ self.assertEqual(size_str(34.5678 * 1024 * 1024 * 1024), '35 GB')
+ self.assertEqual(size_str(5.678 * 1024 * 1024 * 1024 * 1024), '5.7 TB')
+ self.assertEqual(size_str(56.78 * 1024 * 1024 * 1024 * 1024), '57 TB')
+
if __name__ == '__main__':
unittest.main()