@skip('silverlight', 'multiple_execute')
def test_package_back_patching():
 try:
  mod_backup = dict(sys.modules)
  _f_dir = path_combine(testpath.public_testdir, 'the_dir')
  _f_init = path_combine(_f_dir, '__init__.py')
  _f_pkg_abc = path_combine(_f_dir, 'abc1.py')
  _f_pkg_xyz = path_combine(_f_dir, 'xyz1.py')
  ensure_directory_present(_f_dir)
  write_to_file(_f_init, 'import abc1')
  write_to_file(_f_pkg_abc, 'import xyz1')
  write_to_file(_f_pkg_xyz, 'import sys\nsys.foo = "xyz"')
  import the_dir
  (x, y) = (the_dir.abc1, the_dir.xyz1)
  from the_dir import abc1
  from the_dir import xyz1
  AreEqual(x, abc1)
  AreEqual(y, xyz1)
  AreEqual(sys.foo, 'xyz')
  del sys.foo
 finally:
  sys.modules = mod_backup
  os.unlink(_f_init)
  os.unlink(_f_pkg_abc)
  os.unlink(_f_pkg_xyz)

@ skip ( 'silverlight' , 'multiple_execute' ) def test_package_back_patching ( ) : try : mod_backup = dict ( sys . modules ) _f_dir = path_combine ( testpath . public_testdir , 'the_dir' ) _f_init = path_combine ( _f_dir , '__init__.py' ) _f_pkg_abc = path_combine ( _f_dir , 'abc1.py' ) _f_pkg_xyz = path_combine ( _f_dir , 'xyz1.py' ) ensure_directory_present ( _f_dir ) write_to_file ( _f_init , 'import abc1' ) write_to_file ( _f_pkg_abc , 'import xyz1' ) write_to_file ( _f_pkg_xyz , 'import sys\nsys.foo = "xyz"' ) import the_dir ( x , y ) = ( the_dir . abc1 , the_dir . xyz1 ) from the_dir import abc1 from the_dir import xyz1 AreEqual ( x , abc1 ) AreEqual ( y , xyz1 ) AreEqual ( sys . foo , 'xyz' ) del sys . foo finally : sys . modules = mod_backup os . unlink ( _f_init ) os . unlink ( _f_pkg_abc ) os . unlink ( _f_pkg_xyz )
when importing a package item the package should be updated with the child .