diff --git a/bindings/bindingtester/tests/directory.py b/bindings/bindingtester/tests/directory.py index 5f937c4ef8..f1eb9aa13c 100644 --- a/bindings/bindingtester/tests/directory.py +++ b/bindings/bindingtester/tests/directory.py @@ -400,9 +400,10 @@ def generate_path(min_length=0): def generate_prefix(require_unique=False, is_partition=False, min_length=1): + fixed_prefix = 'abcdefg' if not require_unique and min_length == 0 and random.random() < 0.8: return None - elif require_unique or is_partition or min_length > len('abcdefg') or random.random() < 0.5: + elif require_unique or is_partition or min_length > len(fixed_prefix) or random.random() < 0.5: if require_unique: min_length = max(min_length, 16) @@ -416,6 +417,6 @@ def generate_prefix(require_unique=False, is_partition=False, min_length=1): else: return ''.join(chr(random.randrange(ord('\x02'), ord('\x14'))) for i in range(0, length)) else: - prefix = 'abcdefg' + prefix = fixed_prefix generated = prefix[0:random.randrange(min_length, len(prefix))] return generated diff --git a/bindings/bindingtester/tests/directory_state_tree.py b/bindings/bindingtester/tests/directory_state_tree.py index d9603f9b45..ae3b426422 100644 --- a/bindings/bindingtester/tests/directory_state_tree.py +++ b/bindings/bindingtester/tests/directory_state_tree.py @@ -3,13 +3,14 @@ import sys class TreeNodeState: def __init__(self, dir_id, is_directory, is_subspace, has_known_prefix, root, is_partition): self.dir_id = dir_id - self.root = root self.is_directory = is_directory self.is_subspace = is_subspace self.has_known_prefix = has_known_prefix + self.root = root + self.is_partition = is_partition + self.children = {} self.deleted = False - self.is_partition = is_partition class Pointer: def __init__(self, obj): @@ -21,13 +22,15 @@ class Pointer: def set(self, obj): self.obj = obj -# Represents an element of the directory hierarchy, which could have multiple states +# Represents an element of the directory hierarchy. As a result of various operations (e.g. moves) that +# may or may not have succeeded, a node can represent multiple possible states. class DirectoryStateTreeNode: # A cache of directory layers. We mustn't have multiple entries for the same layer layers = {} - # This is the directory that gets used if the chosen directory is invalid - # We must assume any operation could also have been applied to it + # Because our operations may be applied to the default directory in the case that + # the current directory failed to open/create, we compute the result of each operation + # as if it was performed on the current directory and the default directory. default_directory = None # Used for debugging