pyo3/examples/decorator/tests/test_.py
Bruno Kolenbrander 39cac9075b
Organize examples + add __call__ example (#2043)
* Add decorator example crate and split off chapter

* Move not-examples to their own folder

* Add some readme's

* Make black happy

* Make clippy happy

* Add decorator example crate and split off chapter

* Fix ci

* Add empty workspace key

* Try fix ci

* fix ci

* reuse target dir for examples CI

* add pytests folder to makefile recipes

* fix ci, try 2

* add missing pyproject.toml

* remove TOX_TESTENV_PASSENV from Makefile

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-12-15 00:45:26 +00:00

41 lines
613 B
Python

from decorator import Counter
def test_no_args():
@Counter
def say_hello():
print("hello")
say_hello()
say_hello()
say_hello()
say_hello()
assert say_hello.count == 4
def test_arg():
@Counter
def say_hello(name):
print(f"hello {name}")
say_hello("a")
say_hello("b")
say_hello("c")
say_hello("d")
assert say_hello.count == 4
def test_default_arg():
@Counter
def say_hello(name="default"):
print(f"hello {name}")
say_hello("a")
say_hello()
say_hello("c")
say_hello()
assert say_hello.count == 4