def test_existence(self, zip_tree, test_case): """ Ensure that all the files that were supposed to get zipped up make it it into the archive, and ensure that none got in that were not supposed to. """ test_dir, zip_file, unzip_dir = zip_tree real_contents = file_utilities.get_files(unzip_dir) expected_contents = file_utilities.get_files(test_dir) sys.stdout.write("real_contents = %s\n" % (str(real_contents), )) sys.stdout.write( "expected_contents = %s\n" % (str(expected_contents), )) assert set(real_contents) == set(expected_contents)
def test_basic(self): """ Create a directory tree and make sure we get the right result. """ temp_dir = tempfile.mkdtemp() resolve = lambda *x: os.path.join(temp_dir, *x) try: os.mkdir(resolve("a")) os.mkdir(resolve("b")) open(resolve("a", "foo"), "w").close() open(resolve("a", "bar"), "w").close() desired_tree = set(["a", "b", "a/foo", "a/bar"]) assert set(file_utilities.get_files(temp_dir)) == desired_tree finally: shutil.rmtree(temp_dir)
def test_existence(self, test_case): """ Ensure that all the files that were supposed to get created are there, and ensure that none were created that weren't supposed to be. """ test_dir = file_utilities.create_test_directory(test_case) try: real_contents = file_utilities.get_files(test_dir) expected_contents = \ [(i[0] if isinstance(i, tuple) else i) for i in test_case] sys.stdout.write("real_contents = %s\n" % (real_contents, )) sys.stdout.write( "expected_contents = %s\n" % (expected_contents, )) assert set(real_contents) == set(expected_contents) finally: shutil.rmtree(test_dir)