Skip to content
Myr

adding tests for super_len conditional flow

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Nate Prewitt · committed by Nate Prewitt · parent 99364b6 · Browse files · 1 file+28 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+28 added−0 removed

  • tests:+28 added−0 removed

1 file+28 added−0 removed

modified:tests/test_utils.py+28 added
64 unmodified lines
65 with file_obj.open(mode) as fd:66 assert super_len(fd) == 467 assert len(recwarn) == warnings_num6869 def test_super_len_with__len__(self):70 foo = [1,2,3,4]71 len_foo = super_len(foo)72 assert len_foo == 47374 def test_super_len_with_no__len__(self):75 class LenFile(object):76 def __init__(self):77 self.len = 57879 assert super_len(LenFile()) == 58081 def test_super_len_with_tell(self):82 foo = StringIO.StringIO('12345')83 assert super_len(foo) == 584 foo.read(2)85 assert super_len(foo) == 38687 def test_super_len_with_fileno(self):88 with open(__file__, 'rb') as f:89 length = super_len(f)90 file_data = f.read()91 assert length == len(file_data)9293 def test_super_len_with_no_matches(self):94 """Ensure that objects without any length methods default to 0"""95 assert super_len(object()) == 0969798class TestToKeyValList:99100 @pytest.mark.parametrize(101 'value, expected', (
394 unmodified lines