Back to index

obnam  1.1
Public Member Functions | Public Attributes
obnamlib.sizeparse_tests.ByteSizeParserTests Class Reference

List of all members.

Public Member Functions

def setUp
def test_parses_zero
def test_parses_unadorned_size_as_bytes
def test_returns_an_int
def test_parses_unadorned_size_using_default_unit
def test_parses_size_with_byte_unit
def test_parses_size_with_kilo_unit
def test_parses_size_with_kilobyte_unit
def test_parses_size_with_kibibyte_unit
def test_parses_size_with_mega_unit
def test_parses_size_with_megabyte_unit
def test_parses_size_with_mebibyte_unit
def test_parses_size_with_giga_unit
def test_parses_size_with_gigabyte_unit
def test_parses_size_with_gibibyte_unit
def test_raises_error_for_empty_string
def test_raises_error_for_missing_size
def test_raises_error_for_bad_unit
def test_raises_error_for_bad_unit_thats_similar_to_real_one
def test_raises_error_for_bad_default_unit
def test_size_syntax_error_includes_input_string
def test_unit_name_error_includes_input_string

Public Attributes

 p

Detailed Description

Definition at line 22 of file sizeparse_tests.py.


Member Function Documentation

Definition at line 24 of file sizeparse_tests.py.

00024 
00025     def setUp(self):
00026         self.p = obnamlib.ByteSizeParser()
        

Definition at line 40 of file sizeparse_tests.py.

00040 
00041     def test_parses_size_with_byte_unit(self):
00042         self.assertEqual(self.p.parse('123 B'), 123)
        

Definition at line 67 of file sizeparse_tests.py.

00067 
00068     def test_parses_size_with_gibibyte_unit(self):
00069         self.assertEqual(self.p.parse('123 GiB'), 123 * 1024**3)

Definition at line 61 of file sizeparse_tests.py.

00061 
00062     def test_parses_size_with_giga_unit(self):
00063         self.assertEqual(self.p.parse('123 g'), 123 * 1000**3)
        

Definition at line 64 of file sizeparse_tests.py.

00064 
00065     def test_parses_size_with_gigabyte_unit(self):
00066         self.assertEqual(self.p.parse('123 GB'), 123 * 1000**3)
        

Definition at line 49 of file sizeparse_tests.py.

00049 
00050     def test_parses_size_with_kibibyte_unit(self):
00051         self.assertEqual(self.p.parse('123 KiB'), 123 * 1024)
        

Definition at line 43 of file sizeparse_tests.py.

00043 
00044     def test_parses_size_with_kilo_unit(self):
00045         self.assertEqual(self.p.parse('123 k'), 123 * 1000)
        

Definition at line 46 of file sizeparse_tests.py.

00046 
00047     def test_parses_size_with_kilobyte_unit(self):
00048         self.assertEqual(self.p.parse('123 kB'), 123 * 1000)
        

Definition at line 58 of file sizeparse_tests.py.

00058 
00059     def test_parses_size_with_mebibyte_unit(self):
00060         self.assertEqual(self.p.parse('123 MiB'), 123 * 1024**2)
        

Definition at line 52 of file sizeparse_tests.py.

00052 
00053     def test_parses_size_with_mega_unit(self):
00054         self.assertEqual(self.p.parse('123 m'), 123 * 1000**2)
        

Definition at line 55 of file sizeparse_tests.py.

00055 
00056     def test_parses_size_with_megabyte_unit(self):
00057         self.assertEqual(self.p.parse('123 MB'), 123 * 1000**2)
        

Definition at line 30 of file sizeparse_tests.py.

00030 
00031     def test_parses_unadorned_size_as_bytes(self):
00032         self.assertEqual(self.p.parse('123'), 123)
        

Definition at line 36 of file sizeparse_tests.py.

00036 
00037     def test_parses_unadorned_size_using_default_unit(self):
00038         self.p.set_default_unit('KiB')
00039         self.assertEqual(self.p.parse('123'), 123 * 1024)
        

Definition at line 27 of file sizeparse_tests.py.

00027 
00028     def test_parses_zero(self):
00029         self.assertEqual(self.p.parse('0'), 0)
        

Definition at line 82 of file sizeparse_tests.py.

00082 
00083     def test_raises_error_for_bad_default_unit(self):
00084         self.assertRaises(obnamlib.UnitNameError, 
00085                           self.p.set_default_unit, 'km')

Definition at line 76 of file sizeparse_tests.py.

00076 
00077     def test_raises_error_for_bad_unit(self):
00078         self.assertRaises(obnamlib.SizeSyntaxError, self.p.parse, '1 km')

Definition at line 79 of file sizeparse_tests.py.

00079 
00080     def test_raises_error_for_bad_unit_thats_similar_to_real_one(self):
00081         self.assertRaises(obnamlib.UnitNameError, self.p.parse, '1 ib')

Definition at line 70 of file sizeparse_tests.py.

00070 
00071     def test_raises_error_for_empty_string(self):
00072         self.assertRaises(obnamlib.SizeSyntaxError, self.p.parse, '')

Definition at line 73 of file sizeparse_tests.py.

00073 
00074     def test_raises_error_for_missing_size(self):
00075         self.assertRaises(obnamlib.SizeSyntaxError, self.p.parse, 'KiB')

Definition at line 33 of file sizeparse_tests.py.

00033 
00034     def test_returns_an_int(self):
00035         self.assert_(isinstance(self.p.parse('123'), int))
        

Definition at line 86 of file sizeparse_tests.py.

00086 
00087     def test_size_syntax_error_includes_input_string(self):
00088         text = 'asdf asdf'
00089         e = obnamlib.SizeSyntaxError(text)
00090         self.assert_(text in str(e), str(e))

Definition at line 91 of file sizeparse_tests.py.

00091 
00092     def test_unit_name_error_includes_input_string(self):
00093         text = 'asdf asdf'
00094         e = obnamlib.UnitNameError(text)
00095         self.assert_(text in str(e), str(e))
00096 

Member Data Documentation

Definition at line 25 of file sizeparse_tests.py.


The documentation for this class was generated from the following file: