EastAgile / robber.py

BDD / TDD assertion library for Python
MIT License
8 stars 1 forks source link

change, increase, decrease matchers #5

Closed hieueastagile closed 7 years ago

hieueastagile commented 7 years ago

Use case

Example, we have a function

def decrease_it(a):
  return a - 1

We might want to test it, and here's a few possible matchers that we might want to use

expect(decrease_it).to.change(a).from(2).to(1)
expect(decrease_it).to.decrease(a).by(1)
expect(decrease_it).to.increase(a).by(-1)
hieueastagile commented 7 years ago

We might need to resolve this first: https://github.com/EastAgile/robber.py/issues/4

catriuspham commented 7 years ago

I see that we aldready have the chain expect(func).to.change(arg).by(arg). Do we still need these change.from.to, decrease, increase chains?

hieueastagile commented 7 years ago

from... to doesn't work, actually, since from is python keywords, that's why @hotay use change... by instead.

catriuspham commented 7 years ago

How about decrease and increase then? Do we still need to implement them?

hieueastagile commented 7 years ago

We should do.

catriuspham commented 7 years ago

@hieueastagile our current change.by is the same as your suggested increase.by do you want to keep both or just one of them?

hieueastagile commented 7 years ago

@catriuspham Looking into it again. I think we should close this issue, change.by is good enough and it should be the only obvious way for this, we don't need to introduce more ways, it seems to break the Python Zen here.