diff options
author | Kevin Greenan <kmg@box.com> | 2015-04-06 12:52:03 -0700 |
---|---|---|
committer | Kevin Greenan <kmg@box.com> | 2015-04-06 12:52:03 -0700 |
commit | 88c46cc3ac30fca2204080ba2af99f66e7bf8acf (patch) | |
tree | 5165e68c180ba9c5ca93cfe7988cc32bd965cfb1 /test | |
parent | 65976eb0cc749c0ac245c6b0e6a3e830e60ce0a8 (diff) | |
download | pyeclib-88c46cc3ac30fca2204080ba2af99f66e7bf8acf.tar.gz |
Revert "Merged in bloodeagle40234/pyeclib/fix-error-handling (pull request #22)"
This reverts commit 65976eb0cc749c0ac245c6b0e6a3e830e60ce0a8, reversing
changes made to 29c20a8d23d81e7c12546c3e3cf7b91d4061bcf7.
Diffstat (limited to 'test')
-rw-r--r-- | test/test_pyeclib_api.py | 44 |
1 files changed, 1 insertions, 43 deletions
diff --git a/test/test_pyeclib_api.py b/test/test_pyeclib_api.py index 1e1be44..71552c1 100644 --- a/test/test_pyeclib_api.py +++ b/test/test_pyeclib_api.py @@ -26,14 +26,12 @@ from string import ascii_letters, ascii_uppercase, digits import sys import tempfile import unittest -import mock from pyeclib.ec_iface import ECDriverError from pyeclib.ec_iface import ECDriver, VALID_EC_TYPES, ECDriverError, \ PyECLib_EC_Types from test_pyeclib_c import _available_backends import pyeclib_c -from pyeclib_c import error as PyECLibError if sys.version < '3': def b2i(b): @@ -209,7 +207,7 @@ class TestPyECLibDriver(unittest.TestCase): def test_get_metadata_formatted(self): pyeclib_driver = ECDriver(k=12, m=2, ec_type="jerasure_rs_vand", chksum_type="inline_crc32") - + filesize = 1024 * 1024 * 3 file_str = ''.join(random.choice(ascii_letters) for i in range(filesize)) file_bytes = file_str.encode('utf-8') @@ -549,45 +547,5 @@ class TestPyECLibDriver(unittest.TestCase): self.assertTrue( pyeclib_drivers[0].min_parity_fragments_needed() == 1) - def test_ECDriver_error_handling(self): - driver = ECDriver(k=3, m=1, ec_type="jerasure_rs_vand") - - class MockPyECLibError(PyECLibError): - def __str__(self): - return mock.MagicMock() - - with mock.patch('pyeclib_c.decode', side_effect=MockPyECLibError()): - with self.assertRaises(ECDriverError) as cm: - driver.decode([' ' for x in xrange(4)]) - exception = cm.exception - expected = 'Error retrieving the error message from MockPyECLibError' - self.assertEquals(expected, str(exception)) - - def test_ECDriverError_init(self): - - class mock_class(object): - def __init__(self, return_str): - self.return_str = return_str - - def __str__(self): - if self.return_str: - return 'message' - else: - return mock.MagicMock() - - # init with str - error = ECDriverError('message') - self.assertEquals('message', str(error)) - - # init with instance with valid __str__ - error = ECDriverError(mock_class(True)) - self.assertEquals('message', str(error)) - - # init with instance with invalid __str__ - error = ECDriverError(mock_class(False)) - self.assertEquals('Error retrieving the error message from mock_class', - str(error)) - - if __name__ == '__main__': unittest.main() |