cosmicpython/code

Multiply Money NamedTuple in Chapter 1 is no longer a valid operation

jtuz opened this issue · 1 comments

jtuz commented

Talking about value objects, in the chapter 1 there is a Money NamedTuple:

class Money(NamedTupple):
    currency: str
    value: int

also there are some test to demonstrate how a object value works, in the case of Money class, there are tests for add, subtract and multiply, but for multiply operation with python 3.10.5 throw an error:

FAILED test_allocate_order.py::test_can_multiply_money - AssertionError: assert ('MX', 10, 'M...'MX', 10, ...) == Money(currency='MX', value=50)

hjwp commented

I guess you'd need to implement __mul__ for it to work... maybe i should add an explicit hint in the book?