def _resize(self, how_much, fn, randomize=True, close=False, shrink=False): rand = "{}".format(random.random()) path = os.path.join(self.mount(), "test_file") with open(path, "x") as f: f.write(rand) if close: self.v.close() size = os.path.getsize(self.path()) if shrink: size -= util.human_size(how_much) else: size += util.human_size(how_much) fn(how_much, password=self.PASS) self.v.close() self.open() with open(path, "r") as f: assert_equal(rand, f.read()) assert_equal(os.path.getsize(self.path()), size)
def check(tin, tout): assert_equal(tout, util.human_size(tin))