예제 #1
0
 def test_max(self):
     # Test the max range for "convert" for errors.
     prefix = ('geop', 'bronto', 'yotta', 'zetta', 'exa',
               'peta', 'tera', 'giga', 'mega', 'kilo', '')
     suffix = map(lambda s: '1023 ' + (s + 'bytes').capitalize(), prefix)
     self.assertEqual(byt2str.convert((1 << 110) - 1), ', '.join(suffix))
     with self.assertRaises(AssertionError):
         byt2str.convert(1 << 110)
예제 #2
0
 def test_max(self):
     # Test the max range for "convert" for errors.
     prefix = ('geop', 'bronto', 'yotta', 'zetta', 'exa',
               'peta', 'tera', 'giga', 'mega', 'kilo', '')
     suffix = map(lambda s: '1023 ' + (s + 'bytes').capitalize(), prefix)
     self.assertEqual(byt2str.convert((1 << 110) - 1), ', '.join(suffix))
     with self.assertRaises(AssertionError):
         byt2str.convert(1 << 110)
예제 #3
0
 def test_min(self):
     # Check that the "convert" min range is correct.
     self.assertEqual(byt2str.convert(1), '1 Byte')
     with self.assertRaises(AssertionError):
         byt2str.convert(0)
예제 #4
0
 def test_binary(self):
     # Observe if two non-contiguous numbers render well.
     string = byt2str.convert(789 * (1 << 30) + (1 << 10))
     self.assertEqual(string, '789 Gigabytes, 1 Kilobyte')
예제 #5
0
 def test_ternary(self):
     # Ensure that three separate components validate.
     string = byt2str.convert((1 << 40) + (1 << 20) * 123 + 456)
     self.assertEqual(string, '1 Terabyte, 123 Megabytes, 456 Bytes')
예제 #6
0
 def test_min(self):
     # Check that the "convert" min range is correct.
     self.assertEqual(byt2str.convert(1), '1 Byte')
     with self.assertRaises(AssertionError):
         byt2str.convert(0)
예제 #7
0
 def test_binary(self):
     # Observe if two non-contiguous numbers render well.
     string = byt2str.convert(789 * (1 << 30) + (1 << 10))
     self.assertEqual(string, '789 Gigabytes, 1 Kilobyte')
예제 #8
0
 def test_ternary(self):
     # Ensure that three separate components validate.
     string = byt2str.convert((1 << 40) + (1 << 20) * 123 + 456)
     self.assertEqual(string, '1 Terabyte, 123 Megabytes, 456 Bytes')