| 82 | add = ValidatedFunction(add) |
| 83 | |
| 84 | class Stock: |
| 85 | name = NonEmptyString() |
| 86 | shares = PositiveInteger() |
| 87 | price = PositiveFloat() |
| 88 | def __init__(self, name, shares, price): |
| 89 | self.name = name |
| 90 | self.shares = shares |
| 91 | self.price = price |
| 92 | |
| 93 | def __repr__(self): |
| 94 | return f'Stock({self.name!r}, {self.shares!r}, {self.price!r})' |
| 95 | |
| 96 | @property |
| 97 | def cost(self): |
| 98 | return self.shares * self.price |
| 99 | |
| 100 | def sell(self, nshares): |
| 101 | self.shares -= nshares |
| 102 | |
| 103 | sell = ValidatedFunction(sell) # Broken |
| 104 | |
| 105 | |
| 106 |
nothing calls this directly
no test coverage detected