390
398
original_fixture.teardown(None, dict())
391
399
self.assertEquals(['original'], called)
401
def test_python_fixture_does_not_reload_by_default(self):
402
# Even though the dangers of Python's "reload" are subtle and
403
# real, using it can be very nice, particularly with
404
# Launchpad's slow start-up time. By default, though, it is
405
# not used. We will show this by scribbling on one of the
406
# fixtures and showing that the scribble is still there when
408
test_yuixhr_fixture._fixtures_['baseline'].scribble = 'hello'
410
delattr, test_yuixhr_fixture._fixtures_['baseline'], 'scribble')
411
view = create_traversed_view(
412
path_info='/+yuitest/lp/testing/tests/'
413
'test_yuixhr_fixture')
417
'hello', test_yuixhr_fixture._fixtures_['baseline'].scribble)
419
def test_python_fixture_does_not_reload_without_environ_var(self):
420
# As a bit of extra paranoia, we only allow a reload if
421
# 'INTERACTIVE_TESTS' is in the environ. make run-testapp
422
# sets this environmental variable. However, if we don't set
423
# the environment, even if we request a reload it will not
425
test_yuixhr_fixture._fixtures_['baseline'].scribble = 'hello'
427
delattr, test_yuixhr_fixture._fixtures_['baseline'], 'scribble')
428
view = create_traversed_view(
429
path_info='/+yuitest/lp/testing/tests/'
430
'test_yuixhr_fixture', form=dict(reload='1'))
434
'hello', test_yuixhr_fixture._fixtures_['baseline'].scribble)
436
def test_python_fixture_can_reload(self):
437
# Now we will turn reloading fully on, with the environmental
438
# variable and the query string..
439
test_yuixhr_fixture._fixtures_['baseline'].scribble = 'hello'
440
with override_environ(INTERACTIVE_TESTS='1'):
441
view = create_traversed_view(
442
path_info='/+yuitest/lp/testing/tests/'
443
'test_yuixhr_fixture', form=dict(reload='1'))
444
# reloading only happens at render time, so the scribble is
445
# still there for now.
448
'hello', test_yuixhr_fixture._fixtures_['baseline'].scribble)
449
# After a render of the html view, the module is reloaded.
453
getattr(test_yuixhr_fixture._fixtures_['baseline'],
457
def test_python_fixture_resets_fixtures(self):
458
# When we reload, we also clear out _fixtures_. This means
459
# that if you rename or delete something, it won't be hanging
460
# around confusing you into thinking everything is fine after
462
test_yuixhr_fixture._fixtures_['extra_scribble'] = 42
463
with override_environ(INTERACTIVE_TESTS='1'):
464
view = create_traversed_view(
465
path_info='/+yuitest/lp/testing/tests/'
466
'test_yuixhr_fixture', form=dict(reload='1'))
468
# After a render of the html view, the module is reloaded.
472
test_yuixhr_fixture._fixtures_.get('extra_scribble'))
474
def test_python_fixture_reload_in_html(self):
475
# The reload is specifically when we load HTML pages only.
476
test_yuixhr_fixture._fixtures_['extra_scribble'] = 42
477
with override_environ(INTERACTIVE_TESTS='1'):
478
view = create_traversed_view(
479
path_info='/+yuitest/lp/testing/tests/'
480
'test_yuixhr_fixture', form=dict(reload='1'))
482
# After a render of the html view, the module is reloaded.
486
test_yuixhr_fixture._fixtures_.get('extra_scribble'))
488
def test_index_page(self):
489
view = create_traversed_view(path_info='/+yuitest')
491
output = view.render()
495
'href="/+yuitest/lp/testing/tests/test_yuixhr_fixture'))