Hello folks,
I’m kind of weird out by the script console behavior:
The first execution doesn’t print anything, and subsequent ones work perfectly.
But not in every case.
Here’s when it happens:
I have this in a package:
def test(func):
def wrapper():
try:
func()
except AssertionError as e:
message = "failed ({})".format(e)
else:
message = "passed"
return message
return wrapper
and I define tests like this:
@test
def test_func_what():
data = somePackage.func()
expected = "what I expect"
assert data == expected, "expected {}, got {}".format(expected, data)
It does run every time I hit ‘execute’ (I can see test tags being created for example), but doesn’t print anything on the first run, and works perfectly after that.
now, this:
def bar(func):
def wrapper():
try:
func()
except:
m = "bar"
else:
m = "foo"
return m
return wrapper
@bar
def foo():
raise ValueError
Doesn’t trigger this behavior and prints correctly every time.
I should also mention that when defining tests and the decorator in the console, this doesn’t happen.
What am I missing ?