No output on first run for scripts called from script console (decorator issue ?)

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():
		except AssertionError as e:
			message = "failed ({})".format(e)
			message = "passed"
		return message
	return wrapper

and I define tests like this:

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():
			m = "bar"
			m = "foo"
		return m
	return wrapper

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 ?

What version are you using/am I missing a step?
This works first-time for me, on ~8.1.18:

I’m on 8.1.10.

But your screenshot show a scenario that works for me to. Can you try putting the tested function in the same package as the decorator’s definition, then call that function from the console ?

Also seems to work:

Even if I invoke directly from the interpreter:

It doesn’t work for me :confused:

I think there were some fixes to how the script console imports packages/scripts. I’d upgrade when you’re able to.

Also works for me in 8.1.13.