示例#1
0
文件: collect.py 项目: mdavezac/LaDa
def test():
  from tempfile import mkdtemp
  from shutil import rmtree
  from os import makedirs
  from os.path import exists, join
  from pickle import dump
  from pylada.jobfolder import JobFolder, MassExtract
  from dummy import functional

  root = JobFolder()
  for type, trial, size in [('this', 0, 10), ('this', 1, 15), ('that', 2, 20), ('that', 1, 20)]:
    job = root / type / str(trial)
    job.functional = functional
    job.params['indiv'] = size
    if type == 'that': job.params['value'] = True
  job = root / 'this' /  '0' / 'another'
  job.functional = functional
  job.params['indiv'] = 25
  job.params['value'] = 5
  job.params['another'] = 6

  directory =  mkdtemp() # '/tmp/test' # 
  if exists(directory) and directory == '/tmp/test': rmtree(directory)
  if not exists(directory): makedirs(directory)
  try: 
    for name, job in root.iteritems():
      result = job.compute(outdir=join(directory, name))
      assert result.success
      assert {'this/0': 10, 'this/1': 15, 'that/1': 20, \
              'that/2': 20, 'this/0/another': 25 }[name] == result.indiv
    with open(join(directory, 'dict'), 'w') as file: dump(root, file)
    collect = MassExtract(path=join(directory, 'dict'))

    for i, (name, value) in enumerate(collect.functional.iteritems()):
      assert repr(value) == repr(functional)
    assert i == 4
    for i, (name, value) in enumerate(collect.indiv.iteritems()):
      assert {'/this/0/': 10, '/this/1/': 15, '/that/1/': 20, \
              '/that/2/': 20, '/this/0/another/': 25 }[name] == value,\
             Exception((name, value))
    assert i == 4

    try: collect.that
    except: pass
    else: raise RuntimeError()

    collect.unix_re = True
    def check_items(regex, keys, d):
      i = 0
      for name in d[regex].iterkeys():
        i += 1
        assert name in keys, KeyError((regex, name))
      assert i == len(keys), RuntimeError(regex)
    check_items('*/1', set(['/this/1/', '/that/1/']), collect)
    check_items('this', set(['/this/1/', '/this/0/', '/this/0/another/']), collect)
    check_items('that/2/', set(['/that/2/']),collect)
    job = root / 'this' /  '0' / 'another'
    check_items('*/*/another', ['/this/0/another/'], collect)
    check_items('*/*/another/', ['/this/0/another/'], collect)
    check_items('*/another', [], collect)
    check_items('../that', ['/that/2/', '/that/1/'], collect['this'])
    check_items('../that', [], collect['this/0'])
    check_items('../*', ['/this/0/', '/this/1/', '/this/0/another/'], collect['this/0'])
    check_items('../*', ['/this/0/', '/this/1/', '/this/0/another/'], collect['this/*'])
 
    collect.unix_re = False
    check_items('.*/1', set(['/this/1/', '/that/1/']), collect)
    check_items('this', set(['/this/1/', '/this/0/', '/this/0/another/']), collect)
    check_items('that/2/', set(['/that/2/']), collect)
    check_items('.*/.*/another', ['/this/0/another/'], collect)
    check_items('.*/another', ['/this/0/another/'], collect)
 
    collect.unix_re = True
    collect.naked_end = True
    for i, (key, value) in enumerate(collect['*/1'].indiv.iteritems()):
      assert {'/this/0/': 10, '/this/1/': 15, '/that/1/': 20,
              '/that/2/': 20, '/this/0/another/': 25}[key] == value
    assert i == 1

  finally:
    if directory != '/tmp/test': rmtree(directory)
示例#2
0
def test():
  from tempfile import mkdtemp
  from shutil import rmtree
  from os import makedirs
  from os.path import exists, join
  from pickle import loads, dumps
  from pylada.jobfolder import JobFolder
  from copy import deepcopy
  from dummy import functional

  sizes = [10, 15, 20, 25]
  root = JobFolder()
  for type, trial, size in [('this', 0, 10), ('this', 1, 15), ('that', 2, 20), ('that', 1, 20)]:
    jobfolder = root / type / str(trial)
    assert jobfolder.name == "/" + type + "/" + str(trial) + "/"
    jobfolder.functional = functional
    jobfolder.params['indiv'] = size
    if type == 'that': jobfolder.params['value'] = True
      
  assert 'this/0' in root and 'this/1' in root and 'that/2' in root and 'that/1'
  assert '0' in root['this'] and '1' in root['this']
  assert '1' in root['that'] and '2' in root['that']
  assert 'other' not in root
  for jobfolder in root.values():
    assert repr(jobfolder.functional) == repr(functional)
  assert getattr(root['this/0'], 'indiv', 0) == 10
  assert getattr(root['this/1'], 'indiv', 0) == 15
  assert getattr(root['that/1'], 'indiv', 0) == 20
  assert getattr(root['that/2'], 'indiv', 0) == 20
  assert not hasattr(root['this/0'], 'value')
  assert not hasattr(root['this/1'], 'value')
  assert getattr(root['that/1'], 'value', False)
  assert getattr(root['that/2'], 'value', False)

  for key, test in zip(root, ['that/1', 'that/2', 'this/0', 'this/1']): 
    assert key == test
  for key, test in zip(root['that/1'].root, ['that/1', 'that/2', 'this/0', 'this/1']): 
    assert key == test
  for key, test in zip(root['that'], ['1', '2']): assert key == test
  for key, test in zip(root['this'], ['0', '1']): assert key == test
  del root['that/2']
  assert 'that/2' not in root
  
  directory = mkdtemp() # '/tmp/test'
  if exists(directory) and directory == '/tmp/test': rmtree(directory)
  if not exists(directory): makedirs(directory)
  try: 
    for name, jobfolder in root.iteritems():
      result = jobfolder.compute(outdir=join(directory, name))
      assert result.success
      assert exists(join(directory, name))
      assert exists(join(join(directory, name), 'OUTCAR'))
      if name == 'that/1': assert result.indiv == 20
      elif name == 'that/2': assert result.indiv == 15
      elif name == 'this/1': assert result.indiv == 15
      elif name == 'this/0': assert result.indiv == 10
  finally:
    if directory != '/tmp/test': rmtree(directory)

  if exists(directory) and directory == '/tmp/test': rmtree(directory)
  if not exists(directory): makedirs(directory)
  try: 
    for name, jobfolder in loads(dumps(root)).iteritems():
      result = jobfolder.compute(outdir=join(directory, name))
      assert result.success
      assert exists(join(directory, name))
      assert exists(join(join(directory, name), 'OUTCAR'))
      if name == 'that/1': assert result.indiv == 20
      elif name == 'that/2': assert result.indiv == 15
      elif name == 'this/1': assert result.indiv == 15
      elif name == 'this/0': assert result.indiv == 10
  finally:
    if directory != '/tmp/test': rmtree(directory)
  try: 
    for name, jobfolder in deepcopy(root).iteritems():
      result = jobfolder.compute(outdir=join(directory, name))
      assert result.success
      assert exists(join(directory, name))
      assert exists(join(join(directory, name), 'OUTCAR'))
      if name == 'that/1': assert result.indiv == 20
      elif name == 'that/2': assert result.indiv == 15
      elif name == 'this/1': assert result.indiv == 15
      elif name == 'this/0': assert result.indiv == 10
  finally:
    if directory != '/tmp/test': rmtree(directory)

  # makes sure that parent are correctly deepcopied.
  jobfolder = deepcopy(root)
  for value in jobfolder.itervalues(): value.name
示例#3
0
def test():
  from tempfile import mkdtemp
  from shutil import rmtree
  from os import makedirs
  from os.path import exists, join
  from IPython.core.interactiveshell import InteractiveShell
  from pylada.jobfolder import JobFolder
  import pylada
  from dummy import functional
  import __builtin__ 
  __builtin__.raw_input = raw_input

  self = InteractiveShell.instance()

  root = JobFolder()
  for type, trial, size in [('this', 0, 10), ('this', 1, 15), ('that', 2, 20), ('that', 1, 20)]:
    jobfolder = root / type / str(trial)
    jobfolder.functional = functional
    jobfolder.params['indiv'] = size
    if type == 'that': jobfolder.params['value'] = True

  directory =  '/tmp/test' # mkdtemp() # 
  if exists(directory) and directory == '/tmp/test': rmtree(directory)
  if not exists(directory): makedirs(directory)
  try: 
    self.user_ns['jobfolder'] = root
    self.magic("explore jobfolder")
    jobfolder = pylada.interactive.jobfolder
    assert 'this/0' in jobfolder and 'this/1' in jobfolder and 'that/2' in jobfolder and 'that/1'
    assert '0' in jobfolder['this'] and '1' in jobfolder['this']
    assert '1' in jobfolder['that'] and '2' in jobfolder['that']
    assert 'other' not in jobfolder
    for job in jobfolder.values():
      assert repr(job.functional) == repr(functional)
    assert getattr(jobfolder['this/0'], 'indiv', 0) == 10
    assert getattr(jobfolder['this/1'], 'indiv', 0) == 15
    assert getattr(jobfolder['that/1'], 'indiv', 0) == 20
    assert getattr(jobfolder['that/2'], 'indiv', 0) == 20
    assert not hasattr(jobfolder['this/0'], 'value')
    assert not hasattr(jobfolder['this/1'], 'value')
    assert getattr(jobfolder['that/1'], 'value', False)
    assert getattr(jobfolder['that/2'], 'value', False)
    assert pylada.interactive.jobfolder_path is None
    assert 'jobparams' in self.user_ns
    assert jobfolder is self.user_ns['jobparams'].jobfolder

    self.magic("savefolders {0}/dict".format(directory))
    pylada.interactive.jobfolder = None
    pylada.interactive.jobfolder_path = None
    self.magic("explore {0}/dict".format(directory))
    jobfolder = pylada.interactive.jobfolder
    assert 'this/0' in jobfolder and 'this/1' in jobfolder and 'that/2' in jobfolder and 'that/1'
    assert '0' in jobfolder['this'] and '1' in jobfolder['this']
    assert '1' in jobfolder['that'] and '2' in jobfolder['that']
    assert 'other' not in jobfolder
    for job in jobfolder.values():
      assert repr(job.functional) == repr(functional)
    assert getattr(jobfolder['this/0'], 'indiv', 0) == 10
    assert getattr(jobfolder['this/1'], 'indiv', 0) == 15
    assert getattr(jobfolder['that/1'], 'indiv', 0) == 20
    assert getattr(jobfolder['that/2'], 'indiv', 0) == 20
    assert not hasattr(jobfolder['this/0'], 'value')
    assert not hasattr(jobfolder['this/1'], 'value')
    assert getattr(jobfolder['that/1'], 'value', False)
    assert getattr(jobfolder['that/2'], 'value', False)
    assert pylada.interactive.jobfolder_path is not None
    assert 'jobparams' in self.user_ns
    assert jobfolder is self.user_ns['jobparams'].jobfolder
    assert jobfolder is self.user_ns['collect'].jobfolder

    for name, job in root.iteritems():
      if name == 'this/1': continue
      job.compute(outdir=join(directory, name))

    self.magic("explore results".format(directory))
    assert set(['/this/0/', '/that/1/', '/that/2/']) == set(self.user_ns['collect'].iterkeys())
    self.magic("explore errors".format(directory))
    assert len(self.user_ns['collect']) == 0
    self.magic("explore all".format(directory))
    self.magic("explore errors".format(directory))
    assert set(self.user_ns['collect'].keys()) == set(['/this/1/'])
    
  finally: 
    if directory != '/tmp/test': rmtree(directory)
    pass
示例#4
0
def test():
    from tempfile import mkdtemp
    from shutil import rmtree
    from os import makedirs
    from os.path import exists, join
    from pickle import dump
    from pylada.jobfolder import JobFolder, MassExtract
    from dummy import functional

    root = JobFolder()
    for type, trial, size in [('this', 0, 10), ('this', 1, 15),
                              ('that', 2, 20), ('that', 1, 20)]:
        job = root / type / str(trial)
        job.functional = functional
        job.params['indiv'] = size
        if type == 'that': job.params['value'] = True
    job = root / 'this' / '0' / 'another'
    job.functional = functional
    job.params['indiv'] = 25
    job.params['value'] = 5
    job.params['another'] = 6

    directory = mkdtemp()  # '/tmp/test' #
    if exists(directory) and directory == '/tmp/test': rmtree(directory)
    if not exists(directory): makedirs(directory)
    try:
        for name, job in root.iteritems():
            result = job.compute(outdir=join(directory, name))
            assert result.success
            assert {'this/0': 10, 'this/1': 15, 'that/1': 20, \
                    'that/2': 20, 'this/0/another': 25 }[name] == result.indiv
        with open(join(directory, 'dict'), 'w') as file:
            dump(root, file)
        collect = MassExtract(path=join(directory, 'dict'))

        for i, (name, value) in enumerate(collect.functional.iteritems()):
            assert repr(value) == repr(functional)
        assert i == 4
        for i, (name, value) in enumerate(collect.indiv.iteritems()):
            assert {'/this/0/': 10, '/this/1/': 15, '/that/1/': 20, \
                    '/that/2/': 20, '/this/0/another/': 25 }[name] == value,\
                   Exception((name, value))
        assert i == 4

        try:
            collect.that
        except:
            pass
        else:
            raise RuntimeError()

        collect.unix_re = True

        def check_items(regex, keys, d):
            i = 0
            for name in d[regex].iterkeys():
                i += 1
                assert name in keys, KeyError((regex, name))
            assert i == len(keys), RuntimeError(regex)

        check_items('*/1', set(['/this/1/', '/that/1/']), collect)
        check_items('this', set(['/this/1/', '/this/0/', '/this/0/another/']),
                    collect)
        check_items('that/2/', set(['/that/2/']), collect)
        job = root / 'this' / '0' / 'another'
        check_items('*/*/another', ['/this/0/another/'], collect)
        check_items('*/*/another/', ['/this/0/another/'], collect)
        check_items('*/another', [], collect)
        check_items('../that', ['/that/2/', '/that/1/'], collect['this'])
        check_items('../that', [], collect['this/0'])
        check_items('../*', ['/this/0/', '/this/1/', '/this/0/another/'],
                    collect['this/0'])
        check_items('../*', ['/this/0/', '/this/1/', '/this/0/another/'],
                    collect['this/*'])

        collect.unix_re = False
        check_items('.*/1', set(['/this/1/', '/that/1/']), collect)
        check_items('this', set(['/this/1/', '/this/0/', '/this/0/another/']),
                    collect)
        check_items('that/2/', set(['/that/2/']), collect)
        check_items('.*/.*/another', ['/this/0/another/'], collect)
        check_items('.*/another', ['/this/0/another/'], collect)

        collect.unix_re = True
        collect.naked_end = True
        for i, (key, value) in enumerate(collect['*/1'].indiv.iteritems()):
            assert {
                '/this/0/': 10,
                '/this/1/': 15,
                '/that/1/': 20,
                '/that/2/': 20,
                '/this/0/another/': 25
            }[key] == value
        assert i == 1

    finally:
        if directory != '/tmp/test': rmtree(directory)
示例#5
0
def test():
    from tempfile import mkdtemp
    from shutil import rmtree
    from os import makedirs, getcwd, chdir
    from os.path import exists, join
    from IPython.core.interactiveshell import InteractiveShell
    from pylada.jobfolder import JobFolder
    from pylada import interactive
    from dummy import functional
    import __builtin__
    try:
        saveri = __builtin__.raw_input
        __builtin__.raw_input = raw_input

        self = InteractiveShell.instance()

        root = JobFolder()
        for type, trial, size in [('this', 0, 10), ('this', 1, 15),
                                  ('that', 2, 20), ('that', 1, 20)]:
            job = root / type / str(trial)
            job.functional = functional
            job.params['indiv'] = size
            if type == 'that': job.params['value'] = True

        origdir = getcwd()
        directory = mkdtemp()
        if exists(directory) and directory == '/tmp/test': rmtree(directory)
        if not exists(directory): makedirs(directory)
        try:
            self.user_ns['jobfolder'] = root
            self.magic("explore jobfolder")
            self.magic("savefolders {0}/dict".format(directory))
            for name, job in root.iteritems():
                result = job.compute(outdir=join(directory, name))
                assert result.success
                assert {'this/0': 10, 'this/1': 15, 'that/1': 20, \
                        'that/2': 20, 'this/0/another': 25 }[name] == result.indiv

            self.magic("explore {0}/dict".format(directory))
            self.magic("goto this/0")
            assert getcwd() == '{0}/this/0'.format(directory)
            assert interactive.jobfolder.name == '/this/0/'
            self.magic("goto ../1")
            assert getcwd() == '{0}/this/1'.format(directory)
            assert interactive.jobfolder.name == '/this/1/'
            self.magic("goto /that")
            assert getcwd() == '{0}/that'.format(directory)
            assert interactive.jobfolder.name == '/that/'
            self.magic("goto 2")
            assert getcwd() == '{0}/that/2'.format(directory)
            assert interactive.jobfolder.name == '/that/2/'
            self.magic("goto /")
            self.magic("goto next")
            assert getcwd() == '{0}/that/1'.format(directory)
            assert interactive.jobfolder.name == '/that/1/'
            self.magic("goto next")
            assert getcwd() == '{0}/that/2'.format(directory)
            assert interactive.jobfolder.name == '/that/2/'
            self.magic("goto previous")
            assert getcwd() == '{0}/that/1'.format(directory)
            assert interactive.jobfolder.name == '/that/1/'
            self.magic("goto next")
            assert getcwd() == '{0}/this/0'.format(directory)
            assert interactive.jobfolder.name == '/this/0/'
            self.magic("goto next")
            assert getcwd() == '{0}/this/1'.format(directory)
            assert interactive.jobfolder.name == '/this/1/'
            self.magic("goto next")  # no further jobs
            assert getcwd() == '{0}/this/1'.format(directory)
            assert interactive.jobfolder.name == '/this/1/'
            self.magic("goto /")  # go back to root to avoid errors

        finally:
            chdir(origdir)
            try:
                if directory != '/tmp/test': rmtree(directory)
            except:
                pass
    finally:
        __builtin__.raw_input = saveri
示例#6
0
def test(shell):
    from tempfile import mkdtemp
    from shutil import rmtree
    from os import makedirs, getcwd, chdir
    from os.path import exists, join
    from pylada.jobfolder import JobFolder
    from pylada import interactive
    from dummy import functional
 
    root = JobFolder()
    for type, trial, size in [('this', 0, 10), ('this', 1, 15), ('that', 2, 20), ('that', 1, 20)]:
      job = root / type / str(trial)
      job.functional = functional
      job.params['indiv'] = size
      if type == 'that': job.params['value'] = True
 
    origdir = getcwd()
    directory = mkdtemp()
    if exists(directory) and directory == '/tmp/test': rmtree(directory)
    if not exists(directory): makedirs(directory)
    try: 
      shell.user_ns['jobfolder'] = root
      shell.magic("explore jobfolder")
      shell.magic("savefolders {0}/dict".format(directory))
      for name, job in root.iteritems():
        result = job.compute(outdir=join(directory, name))
        assert result.success
        assert {'this/0': 10, 'this/1': 15, 'that/1': 20, \
                'that/2': 20, 'this/0/another': 25 }[name] == result.indiv
 
      shell.magic("explore {0}/dict".format(directory))
      shell.magic("goto this/0")
      assert getcwd() == '{0}/this/0'.format(directory)
      assert interactive.jobfolder.name == '/this/0/'
      shell.magic("goto ../1")
      assert getcwd() == '{0}/this/1'.format(directory)
      assert interactive.jobfolder.name == '/this/1/'
      shell.magic("goto /that")
      assert getcwd() == '{0}/that'.format(directory)
      assert interactive.jobfolder.name == '/that/'
      shell.magic("goto 2")
      assert getcwd() == '{0}/that/2'.format(directory)
      assert interactive.jobfolder.name == '/that/2/'
      shell.magic("goto /")
      shell.magic("goto next")
      assert getcwd() == '{0}/that/1'.format(directory)
      assert interactive.jobfolder.name == '/that/1/'
      shell.magic("goto next")
      assert getcwd() == '{0}/that/2'.format(directory)
      assert interactive.jobfolder.name == '/that/2/'
      shell.magic("goto previous")
      assert getcwd() == '{0}/that/1'.format(directory)
      assert interactive.jobfolder.name == '/that/1/'
      shell.magic("goto next")
      assert getcwd() == '{0}/this/0'.format(directory)
      assert interactive.jobfolder.name == '/this/0/'
      shell.magic("goto next")
      assert getcwd() == '{0}/this/1'.format(directory)
      assert interactive.jobfolder.name == '/this/1/'
      shell.magic("goto next") # no further jobs
      assert getcwd() == '{0}/this/1'.format(directory)
      assert interactive.jobfolder.name == '/this/1/'
      shell.magic("goto /") # go back to root to avoid errors
      
    finally: 
      chdir(origdir)
      try: 
        if directory != '/tmp/test': rmtree(directory)
      except: pass
示例#7
0
def test():
    from tempfile import mkdtemp
    from shutil import rmtree
    from os import makedirs
    from os.path import exists, join
    from IPython.core.interactiveshell import InteractiveShell
    from pylada.jobfolder import JobFolder
    import pylada
    from dummy import functional
    import __builtin__
    __builtin__.raw_input = raw_input

    self = InteractiveShell.instance()

    root = JobFolder()
    for type, trial, size in [('this', 0, 10), ('this', 1, 15),
                              ('that', 2, 20), ('that', 1, 20)]:
        jobfolder = root / type / str(trial)
        jobfolder.functional = functional
        jobfolder.params['indiv'] = size
        if type == 'that': jobfolder.params['value'] = True

    directory = '/tmp/test'  # mkdtemp() #
    if exists(directory) and directory == '/tmp/test': rmtree(directory)
    if not exists(directory): makedirs(directory)
    try:
        self.user_ns['jobfolder'] = root
        self.magic("explore jobfolder")
        jobfolder = pylada.interactive.jobfolder
        assert 'this/0' in jobfolder and 'this/1' in jobfolder and 'that/2' in jobfolder and 'that/1'
        assert '0' in jobfolder['this'] and '1' in jobfolder['this']
        assert '1' in jobfolder['that'] and '2' in jobfolder['that']
        assert 'other' not in jobfolder
        for job in jobfolder.values():
            assert repr(job.functional) == repr(functional)
        assert getattr(jobfolder['this/0'], 'indiv', 0) == 10
        assert getattr(jobfolder['this/1'], 'indiv', 0) == 15
        assert getattr(jobfolder['that/1'], 'indiv', 0) == 20
        assert getattr(jobfolder['that/2'], 'indiv', 0) == 20
        assert not hasattr(jobfolder['this/0'], 'value')
        assert not hasattr(jobfolder['this/1'], 'value')
        assert getattr(jobfolder['that/1'], 'value', False)
        assert getattr(jobfolder['that/2'], 'value', False)
        assert pylada.interactive.jobfolder_path is None
        assert 'jobparams' in self.user_ns
        assert jobfolder is self.user_ns['jobparams'].jobfolder

        self.magic("savefolders {0}/dict".format(directory))
        pylada.interactive.jobfolder = None
        pylada.interactive.jobfolder_path = None
        self.magic("explore {0}/dict".format(directory))
        jobfolder = pylada.interactive.jobfolder
        assert 'this/0' in jobfolder and 'this/1' in jobfolder and 'that/2' in jobfolder and 'that/1'
        assert '0' in jobfolder['this'] and '1' in jobfolder['this']
        assert '1' in jobfolder['that'] and '2' in jobfolder['that']
        assert 'other' not in jobfolder
        for job in jobfolder.values():
            assert repr(job.functional) == repr(functional)
        assert getattr(jobfolder['this/0'], 'indiv', 0) == 10
        assert getattr(jobfolder['this/1'], 'indiv', 0) == 15
        assert getattr(jobfolder['that/1'], 'indiv', 0) == 20
        assert getattr(jobfolder['that/2'], 'indiv', 0) == 20
        assert not hasattr(jobfolder['this/0'], 'value')
        assert not hasattr(jobfolder['this/1'], 'value')
        assert getattr(jobfolder['that/1'], 'value', False)
        assert getattr(jobfolder['that/2'], 'value', False)
        assert pylada.interactive.jobfolder_path is not None
        assert 'jobparams' in self.user_ns
        assert jobfolder is self.user_ns['jobparams'].jobfolder
        assert jobfolder is self.user_ns['collect'].jobfolder

        for name, job in root.iteritems():
            if name == 'this/1': continue
            job.compute(outdir=join(directory, name))

        self.magic("explore results".format(directory))
        assert set(['/this/0/', '/that/1/',
                    '/that/2/']) == set(self.user_ns['collect'].iterkeys())
        self.magic("explore errors".format(directory))
        assert len(self.user_ns['collect']) == 0
        self.magic("explore all".format(directory))
        self.magic("explore errors".format(directory))
        assert set(self.user_ns['collect'].keys()) == set(['/this/1/'])

    finally:
        if directory != '/tmp/test': rmtree(directory)
        pass