Example #1
0
 def teardown_method(self, method):
     d = self.d
     d.parent.chdir()  # Always need a valid curdir to avoid OSErrors.
     if dump:
         dump_path(d)
     if cleanup:
         d.rmtree()
         if d.exists():
             raise AssertionError("unable to delete temp dir %s" % d)
     else:
         print("Not deleting test directory", d)
Example #2
0
 def teardown_method(self, method):
     d = self.d
     d.parent.chdir()  # Always need a valid curdir to avoid OSErrors.
     if dump:
         dump_path(d)
     if cleanup:
         d.rmtree()
         if d.exists():
             raise AssertionError("unable to delete temp dir %s" % d)
     else:
         print("Not deleting test directory", d)
Example #3
0
def dump_path(path, prefix="", tab="    ", file=None):
    if file is None:
        file = sys.stdout
    p = AbstractPath(path)
    if p.islink():
        print("%s%s -> %s" % (prefix, p.name, p.read_link()), file=file)
    elif p.isdir():
        print("%s%s:" % (prefix, p.name), file=file)
        for p2 in p.listdir():
            dump_path(p2, prefix + tab, tab, file)
    else:
        print("%s%s  (%d)" % (prefix, p.name, p.size()), file=file)
Example #4
0
def dump_path(path, prefix="", tab="    ", file=None):
    if file is None:
        file = sys.stdout
    p = AbstractPath(path)
    if   p.islink():
        print("%s%s -> %s" % (prefix, p.name, p.read_link()), file=file)
    elif p.isdir():
        print("%s%s:" % (prefix, p.name), file=file)
        for p2 in p.listdir():
            dump_path(p2, prefix+tab, tab, file)
    else:
        print("%s%s  (%d)" % (prefix, p.name, p.size()), file=file)