Skip to content

Commit

Permalink
Fixed len(Packet) behavior. Resolves #29
Browse files Browse the repository at this point in the history
  • Loading branch information
mcferrill committed Apr 19, 2022
1 parent 7f17cdc commit 43b9223
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
trigger:
- master

name: '1.1.16'
name: '1.1.17'

jobs:

Expand Down
2 changes: 1 addition & 1 deletion chapter10/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .c10 import C10, TYPES
from .packet import Packet, InvalidPacket
version = '1.1.15'
version = '1.1.17'
2 changes: 1 addition & 1 deletion chapter10/packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def __len__(self):
return len(self._messages)
if hasattr(self, 'count'):
return self.count
elif hasattr(self, 'Message') and self.Message.length:
elif getattr(self, 'Message', None) and self.Message.length:
msg_size = self.Message.length
if getattr(self.Message, 'FORMAT', None):
msg_size += self.Message.FORMAT.calcsize() // 8
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "pychapter10"
version = "0.1.16"
version = "1.1.17"
description = "A parser library for the IRIG 106 Chapter 10 data format."
authors = [
{name = "Micah Ferrill", email = "ferrillm@avtest.com"},
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/test_pcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ def test_packed(packet):
def test_throughput(throughput):
with pytest.raises(StopIteration):
next(throughput)


def test_throughput_len(throughput):
with pytest.raises(TypeError):
len(throughput)

0 comments on commit 43b9223

Please sign in to comment.