def setUp(self): self.data_stores = get_test_data_stores() # This is just because MongoHashMap does not handle ints on dictionary keys test_specs = get_test_specs(only_lists=True) test_operations = get_test_operations() self.rnd = Random(42) self.rnd.shuffle(test_specs) self.rnd.shuffle(test_operations) self.indexed_operations = test_operations[:len(test_operations) / 2] self.indexed_specs = test_specs[:len(test_specs) / 2] + self.indexed_operations self.not_indexed_specs = test_specs[ len(test_specs) / 2:] + test_operations[len(test_operations) / 2:] self.cached_functions = [] for i, ds in enumerate(self.data_stores): # Populate the data stores for j, spec in enumerate(self.indexed_specs): ds[spec] = j # it's defined inside an instance method hehehe if type(func).__name__ == 'FunctionWrapper': # func might be changed during tests, we need it to be a function module = inspect.getmodule(TestDataStore) setattr(module, 'func', func.operation_class.func)
def setUp(self): self.data_stores = [ FileDataStore(tempfile.mktemp(), serializer=RawSerializer()), FileDataStore(tempfile.mktemp(), use_class_name=True), FileDataStore(tempfile.mktemp(), serializer=PickleSerializer()), ] self.test_specs = get_test_specs(only_lists=True)
def setUp(self): self.data_stores = [ MongoHashMap('test.with_grid_fs', use_gridfs=True), MongoHashMap('test.test') ] for ds in self.data_stores: ds.coll.drop() self.test_specs = get_test_specs(only_lists=True) for ds in self.data_stores: for spec in self.test_specs: ds[spec] = "asdf"
def test_create_refactor(self): specs = get_test_specs(easy=True) + get_test_data_stores() specs = [ e for e in specs if not isinstance(e, SpecB) and not isinstance(e, SpecWithDefault) ] specs.append(func(Spec())) specs.append(func(A())) specs.append(func(A(H(0)))) specs.append(func(A(H(1)))) for s1 in specs: for s2 in specs: s1_dict = s1.to_dict() s2_dict = s2.to_dict() diff = Diff.build(s1_dict, s2_dict) r = diff.create_refactor() refactored_dict = r.bind(s1_dict).execute() assert refactored_dict == s2_dict