def test_threading_import(tmpdir):
 tmp_file = tmpdir.join('test.txt')
 tmp_file.write('Testing')
 ar = ArchiveFile(tmp_file.strpath, 'r')
 q1 = Queue()
 q2 = Queue()
 def foo():
  with ar:
   q1.put(1)
   assert (q2.get() == 2)
   assert (q2.get() == 3)
 thread = Thread(target=foo)
 thread.start()
 with ar:
  q2.put(2)
  assert (q1.get() == 1)
 q2.put(3)
 thread.join()

def test_threading_import ( tmpdir ) : tmp_file = tmpdir . join ( 'test.txt' ) tmp_file . write ( 'Testing' ) ar = ArchiveFile ( tmp_file . strpath , 'r' ) q1 = Queue ( ) q2 = Queue ( ) def foo ( ) : with ar : q1 . put ( 1 ) assert ( q2 . get ( ) == 2 ) assert ( q2 . get ( ) == 3 ) thread = Thread ( target = foo ) thread . start ( ) with ar : q2 . put ( 2 ) assert ( q1 . get ( ) == 1 ) q2 . put ( 3 ) thread . join ( )
on python 3 .