[py-dev] Re: [py-svn] r12006 - in py/dist/py/test: . terminal
Jan Balster
jan at balster.info
Mon May 9 16:37:53 CEST 2005
hpk at codespeak.net wrote:
> Author: hpk
> Date: Fri May 6 12:36:56 2005
> New Revision: 12006
>
> Modified:
> py/dist/py/test/collect.py
> py/dist/py/test/item.py
> py/dist/py/test/terminal/remote.py
> Log:
> make building the collector's tree more persistent
> by introducing "buildname2items()" which is responsible
> for building a dictionary mapping names to collectors/items.
> the default run()/join() methods now build this dictionary
> and cache it.
>
> The net result is that py lib's own and PyPy's test runs
> run some 10% faster and are somewhat saner!
>
Hi Holger,
I have a problem with this change. (Test)Items generated by a generator
collector are not executed in the expected order.
Can you change that?
Jan
########################################################################
TestCase:
########################################################################
test_counter = -1
test_list = []
def inc_counter_and_test(expected_number):
global test_counter
test_counter += 1
test_list.append(expected_number)
counter = test_counter
assert counter == expected_number
def order_of_execution(expected_list):
t = test_list
print 'expected', expected_list
print 'but got ', t
assert t == expected_list
def test_generator():
for i in range(5):
yield inc_counter_and_test, i
yield order_of_execution, range(5)
#######################################################################################
Output:
....
def order_of_execution(expected_list):
t = test_list
print 'expected', expected_list
print 'but got ', t
E assert t == expected_list
> assert [4, 2, 3, 0, 1] == [0, 1, 2, 3, 4]
[/.../test_order_of_execution.py:16]
[modulepath: test_generator[5]]
- - - - - - - - - - - - - - - - - - - - - - - - - [5]: recorded stdout
- - - - - - - - - - - - - - - - - - - - - - - - -
expected [0, 1, 2, 3, 4]
but got [4, 2, 3, 0, 1]
More information about the Pytest-dev
mailing list