Python filecmp.cmp() Examples
The following are 30
code examples of filecmp.cmp().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
filecmp
, or try the search function
.
Example #1
Source File: ds.py From macops with Apache License 2.0 | 6 votes |
def SyncShadowHash(username, shadow_name): """Sync the password hash for the shadow admin account with the user's.""" shadow_guid = UserAttribute(shadow_name, 'GeneratedUID') user_hash = '/var/db/shadow/hash/%s' % username if not os.path.exists(user_hash): user_guid = UserAttribute(username, 'GeneratedUID')[0] user_hash = '/var/db/shadow/hash/%s' % user_guid shadow_hash = '/var/db/shadow/hash/%s' % shadow_guid[0] try: if (os.path.exists(shadow_hash) and os.path.isfile(shadow_hash) and filecmp.cmp(user_hash, shadow_hash, shallow=False)): # everything is as should be pass else: shutil.copy2(user_hash, shadow_hash) except (IOError, OSError), err: raise DSException('Error creating the shadow admin hash for ' '%s-admin: %s' % (username, err))
Example #2
Source File: check_consistent.py From typeshed with Apache License 2.0 | 6 votes |
def main(): files = [os.path.join(root, file) for root, dir, files in os.walk('.') for file in files] no_symlink = 'You cannot use symlinks in typeshed, please copy {} to its link.' for file in files: _, ext = os.path.splitext(file) if ext == '.pyi' and os.path.islink(file): raise ValueError(no_symlink.format(file)) for file1, *others in consistent_files: f1 = os.path.join(os.getcwd(), file1) for file2 in others: f2 = os.path.join(os.getcwd(), file2) if not filecmp.cmp(f1, f2): raise ValueError( "File {f1} does not match file {f2}. Please copy it to {f2}\n" "Run either:\ncp {f1} {f2}\nOr:\ncp {f2} {f1}".format(f1=file1, f2=file2) )
Example #3
Source File: test_libzfs_core.py From pyzfs with Apache License 2.0 | 6 votes |
def test_recv_full(self): src = ZFSTest.pool.makeName("fs1@snap") dst = ZFSTest.pool.makeName("fs2/received-1@snap") with temp_file_in_fs(ZFSTest.pool.makeName("fs1")) as name: lzc.lzc_snapshot([src]) with tempfile.TemporaryFile(suffix='.ztream') as stream: lzc.lzc_send(src, None, stream.fileno()) stream.seek(0) lzc.lzc_receive(dst, stream.fileno()) name = os.path.basename(name) with zfs_mount(src) as mnt1, zfs_mount(dst) as mnt2: self.assertTrue( filecmp.cmp(os.path.join(mnt1, name), os.path.join(mnt2, name), False))
Example #4
Source File: test_put_get_for_gcp_account.py From snowflake-connector-python with Apache License 2.0 | 6 votes |
def test_auto_compress_off_gcp(tmpdir, conn_cnx, db_parameters): """[gcp] Puts and Gets a small text using gcp with no auto compression.""" fname = str(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data', 'example.json')) with conn_cnx( user=db_parameters['gcp_user'], account=db_parameters['gcp_account'], password=db_parameters['gcp_password'], ) as cnx: with cnx.cursor() as cursor: try: cursor.execute("create or replace stage teststage") cursor.execute("put file://{} @teststage auto_compress=false".format(fname)) cursor.execute("get @teststage file://{}".format(str(tmpdir))) downloaded_file = os.path.join(str(tmpdir), 'example.json') assert cmp(fname, downloaded_file) finally: cursor.execute("drop stage teststage")
Example #5
Source File: link_pyqt.py From qutebrowser with GNU General Public License v3.0 | 6 votes |
def needs_update(source, dest): """Check if a file to be linked/copied needs to be updated.""" if os.path.islink(dest): # No need to delete a link and relink -> skip this return False elif os.path.isdir(dest): diffs = filecmp.dircmp(source, dest) ignored = get_ignored_files(source, diffs.left_only) has_new_files = set(ignored) != set(diffs.left_only) return (has_new_files or diffs.right_only or diffs.common_funny or diffs.diff_files or diffs.funny_files) else: return not filecmp.cmp(source, dest)
Example #6
Source File: test_put_get_for_gcp_account.py From snowflake-connector-python with Apache License 2.0 | 6 votes |
def test_auto_compress_off_gcp(tmpdir, conn_cnx, db_parameters): """[gcp] Puts and Gets a small text using gcp with no auto compression.""" fname = str(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data', 'example.json')) with conn_cnx( user=db_parameters['gcp_user'], account=db_parameters['gcp_account'], password=db_parameters['gcp_password'], ) as cnx: with cnx.cursor() as cursor: try: cursor.execute("create or replace stage teststage") cursor.execute("put file://{} @teststage auto_compress=false".format(fname)) cursor.execute("get @teststage file://{}".format(str(tmpdir))) downloaded_file = os.path.join(str(tmpdir), 'example.json') assert cmp(fname, downloaded_file) finally: cursor.execute("drop stage teststage")
Example #7
Source File: test_make_tracks.py From pyGenomeTracks with GNU General Public License v3.0 | 6 votes |
def test_make_tracks(): outfile = NamedTemporaryFile(suffix='.ini', prefix='pyGenomeTracks_test_', delete=False) args = "--trackFiles {0} {1} {2} {3} --out {4}" \ "".format(os.path.join(relative_path, 'Li_et_al_2015.h5'), os.path.join(relative_path, 'bigwig_chrx_2e6_5e6.bw'), os.path.join(relative_path, 'tad_classification.bed'), os.path.join(relative_path, 'epilog.qcat.bgz'), outfile.name).split() print("using args: {}".format(" ".join(args))) pygenometracks.makeTracksFile.main(args) if filecmp.cmp(outfile.name, os.path.join(ROOT, 'master_tracks.ini')) is False: import difflib diff = difflib.unified_diff(open(outfile.name).readlines(), open(os.path.join(ROOT, 'master_tracks.ini')).readlines(), lineterm='') print(''.join(list(diff))) assert(filecmp.cmp(outfile.name, os.path.join(ROOT, 'master_tracks.ini')) is True) os.remove(outfile.name)
Example #8
Source File: test.py From geojsoncontour with MIT License | 6 votes |
def test_contour_to_geojson_extra_properties(self): contour = self.create_contour() ndigits = 3 geojson_properties = { 'description': 'A description', 'stroke-opacity': 1.0 } geojsoncontour.contour_to_geojson( contour=contour, geojson_filepath=self.geojson_properties_file, min_angle_deg=self.config.min_angle_between_segments, ndigits=ndigits, unit=self.config.unit, stroke_width=5, geojson_properties=geojson_properties ) self.assertTrue(os.path.exists(self.geojson_properties_file)) self.assertTrue(filecmp.cmp(self.benchmark_geojson_properties_file, self.geojson_properties_file)) os.remove(self.geojson_properties_file)
Example #9
Source File: file_expander.py From screeps-starter-python with MIT License | 6 votes |
def expand_files(self): """Creates a flattened file structure of all user-defined screeps code Copies all modified or new .py files found directly under src/, or in subdirectories under src/, to __py_build__. :return: total number of files copied to __py_build__ :rtype: int """ target_files = self.find_target_file_paths() copied_files = 0 for target in target_files: partner = self.build_dir.joinpath(target.name) target_path, partner_path = str(target.absolute()), str(partner.absolute()) if not (partner.is_file() and filecmp.cmp(target_path, partner_path)): shutil.copy2(target_path, partner_path) copied_files += 1 return copied_files
Example #10
Source File: file_expander.py From screeps-starter-python with MIT License | 6 votes |
def verify_defs_integrity(source_dir, build_dir): """Verifies integrity of defs/ folder in __py_build__ File contents under src/defs are compared against __py_build__/defs; a file update will only be triggered by modifications to files under src/defs. :rtype: None """ defs_source_files = [f.absolute() for f in source_dir.glob('**/*.py')] for file in defs_source_files: slice_index = file.parts.index('src') + 1 partner = build_dir.joinpath(*file.parts[slice_index:]) if not partner.is_file() or not filecmp.cmp(str(file), str(partner)): shutil.copy2(str(file), str(partner))
Example #11
Source File: test_mritopng.py From mritopng with MIT License | 6 votes |
def test_convert_file_with_negative_values(self): """ Tests DICOM files with negative values, which are clipped to 0 """ cases = ['000012.dcm', '000017.dcm'] curr_path = os.path.dirname(os.path.realpath(__file__)) for case in cases: sample_path = os.path.join(curr_path, 'data', 'samples', case) expected_path = os.path.join(curr_path, 'data', 'expected', case + '.png') actual_path = os.path.join(test_out_path, case + '.png') print('Actual File Path: %s' % actual_path) # Try the file conversion try: mritopng.convert_file(sample_path, actual_path) except Exception as err: self.fail('%s' % err) self.assertTrue(filecmp.cmp(actual_path, expected_path), 'PNG generated from dicom1 does not match the expected version')
Example #12
Source File: test_mritopng.py From mritopng with MIT License | 6 votes |
def test_convert_file(self): """ Tests conversion of a single DICOM file """ curr_path = os.path.dirname(os.path.realpath(__file__)) sample_path = os.path.join(curr_path, 'data', 'samples', 'dicom1') expected_path = os.path.join(curr_path, 'data', 'expected', 'dicom1.png') actual_path = os.path.join(test_out_path, 'dicom1.png') print('Actual File Path: %s' % actual_path) # Try the file conversion try: mritopng.convert_file(sample_path, actual_path) except Exception as err: self.fail('%s' % err) self.assertTrue(filecmp.cmp(actual_path, expected_path), 'PNG generated from dicom1 does not match the expected version')
Example #13
Source File: test_file_structure_and_content.py From sec-edgar-downloader with MIT License | 6 votes |
def test_file_contents(downloader): dl, dl_path = downloader filing_type = "8-K" ticker = "AAPL" before_date = "20191115" num_downloaded = dl.get(filing_type, ticker, 1, before_date=before_date) assert num_downloaded == 1 downloaded_file_path = dl_path / "sec_edgar_filings" / ticker / filing_type downloaded_filings = list(downloaded_file_path.glob("*")) assert len(downloaded_filings) == 1 downloaded_file_path = downloaded_file_path / downloaded_filings[0] # https://stackoverflow.com/q/1072569 expected_data_path = Path(f"tests/sample_filings/apple_8k_{before_date}.txt") if expected_data_path.exists(): # Only run this check if the sample filing exists # This check is required since the distributed python package will not # contain the sample filings test data due to size constraints assert filecmp.cmp(expected_data_path, downloaded_file_path, shallow=False)
Example #14
Source File: core.py From deplicate with MIT License | 6 votes |
def _binarycmp(filelist, onerror): file0, file1 = filelist try: if filecmp(file0.path, file1.path, shallow=False): dupdict = {True: filelist} else: dupdict = {} errlist = [] except (IOError, OSError) as exc: if onerror is not None: onerror(exc, abspath(exc.filename)) dupdict = {} errlist = filelist return dupdict, errlist
Example #15
Source File: authentication_test.py From simple-cryptography with MIT License | 6 votes |
def helper(Sender, f, h0): fcopy = f + "copy.mp4" fstream = f + "stream.bin" sender = Sender(path=f, buffersize=1024) sender.write_file(path=fstream) computed_h0 = sender.get_first_hash() assert h0 == computed_h0 receiver = StreamReceiver(path=fstream, h=computed_h0, buffersize=1024) receiver.write_file(path=fcopy) assert filecmp.cmp(fcopy, f) subprocess.run(["rm", fcopy]) subprocess.run(["rm", fstream])
Example #16
Source File: test_compression.py From airflow with Apache License 2.0 | 6 votes |
def test_uncompress_file(self): # Testing txt file type self.assertRaisesRegex(NotImplementedError, "^Received .txt format. Only gz and bz2.*", compression.uncompress_file, **{'input_file_name': None, 'file_extension': '.txt', 'dest_dir': None }) # Testing gz file type fn_txt = self._get_fn('.txt') fn_gz = self._get_fn('.gz') txt_gz = compression.uncompress_file(fn_gz, '.gz', self.tmp_dir) self.assertTrue(filecmp.cmp(txt_gz, fn_txt, shallow=False), msg="Uncompressed file doest match original") # Testing bz2 file type fn_bz2 = self._get_fn('.bz2') txt_bz2 = compression.uncompress_file(fn_bz2, '.bz2', self.tmp_dir) self.assertTrue(filecmp.cmp(txt_bz2, fn_txt, shallow=False), msg="Uncompressed file doest match original")
Example #17
Source File: ofsorter.py From OnlyFans with GNU General Public License v3.0 | 6 votes |
def sorter(user_directory, api_type, location, metadata): legacy_directory = os.path.join(user_directory, api_type, location) if not os.path.isdir(legacy_directory): return legacy_files = os.listdir(legacy_directory) metadata_directory = os.path.join( user_directory, "Metadata", api_type+".json") results = list(chain(*metadata["valid"])) for result in results: legacy_filepath = os.path.join(legacy_directory, result["filename"]) filepath = os.path.join(result["directory"], result["filename"]) if result["filename"] in legacy_files: if os.path.isfile(filepath): same_file = filecmp.cmp( legacy_filepath, filepath, shallow=False) if same_file: os.remove(filepath) else: os.remove(legacy_filepath) continue shutil.move(legacy_filepath, filepath) if not os.listdir(legacy_directory): os.removedirs(legacy_directory)
Example #18
Source File: ipsec.py From neutron-vpnaas with Apache License 2.0 | 6 votes |
def _config_changed(self): secrets_file = os.path.join( self.etc_dir, 'ipsec.secrets') config_file = os.path.join( self.etc_dir, 'ipsec.conf') if not os.path.isfile(secrets_file + '.old'): return True if not os.path.isfile(config_file + '.old'): return True if not filecmp.cmp(secrets_file, secrets_file + '.old'): return True if not filecmp.cmp(config_file, config_file + '.old'): return True return False
Example #19
Source File: test_bots.py From zulip with Apache License 2.0 | 6 votes |
def test_add_bot_with_user_avatar(self) -> None: email = 'hambot-bot@zulip.testserver' realm = get_realm('zulip') self.login('hamlet') self.assert_num_bots_equal(0) with get_test_image_file('img.png') as fp: self.create_bot(file=fp) profile = get_user(email, realm) # Make sure that avatar image that we've uploaded is same with avatar image in the server self.assertTrue(filecmp.cmp(fp.name, os.path.splitext(avatar_disk_path(profile))[0] + ".original")) self.assert_num_bots_equal(1) self.assertEqual(profile.avatar_source, UserProfile.AVATAR_FROM_USER) self.assertTrue(os.path.exists(avatar_disk_path(profile)))
Example #20
Source File: test_mritopng.py From mritopng with MIT License | 6 votes |
def test_convert_file_auto_contrast(self): cases = ['dicom1', '000012.dcm', '000017.dcm'] curr_path = os.path.dirname(os.path.realpath(__file__)) os.makedirs(os.path.join(test_out_path, 'auto-contrast')) for case in cases: sample_path = os.path.join(curr_path, 'data', 'samples', case) expected_path = os.path.join(curr_path, 'data', 'expected', 'auto-contrast', case + '.png') actual_path = os.path.join(test_out_path, 'auto-contrast', case + '.png') print('Actual File Path: %s' % actual_path) # Try the file conversion try: print('>>> Here') mritopng.convert_file(sample_path, actual_path, auto_contrast=True) print('<<<') except Exception as err: traceback.print_exc(file=sys.stdout) self.fail('%s' % err) self.assertTrue(filecmp.cmp(actual_path, expected_path), 'PNG generated from dicom1 does not match the expected version')
Example #21
Source File: test_filecmp.py From BinderFilter with MIT License | 5 votes |
def test_matching(self): self.assertTrue(filecmp.cmp(self.name, self.name_same), "Comparing file to itself fails") self.assertTrue(filecmp.cmp(self.name, self.name_same, shallow=False), "Comparing file to itself fails") self.assertTrue(filecmp.cmp(self.name, self.name, shallow=False), "Comparing file to identical file fails") self.assertTrue(filecmp.cmp(self.name, self.name), "Comparing file to identical file fails")
Example #22
Source File: test_tinypages.py From Mastering-Elasticsearch-7.0 with MIT License | 5 votes |
def test_tinypages(tmpdir): html_dir = pjoin(str(tmpdir), 'html') doctree_dir = pjoin(str(tmpdir), 'doctrees') # Build the pages with warnings turned into errors cmd = [sys.executable, '-msphinx', '-W', '-b', 'html', '-d', doctree_dir, pjoin(dirname(__file__), 'tinypages'), html_dir] proc = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True) out, err = proc.communicate() assert proc.returncode == 0, \ "sphinx build failed with stdout:\n{}\nstderr:\n{}\n".format(out, err) if err: pytest.fail("sphinx build emitted the following warnings:\n{}" .format(err)) assert isdir(html_dir) def plot_file(num): return pjoin(html_dir, 'some_plots-{0}.png'.format(num)) range_10, range_6, range_4 = [plot_file(i) for i in range(1, 4)] # Plot 5 is range(6) plot assert filecmp.cmp(range_6, plot_file(5)) # Plot 7 is range(4) plot assert filecmp.cmp(range_4, plot_file(7)) # Plot 11 is range(10) plot assert filecmp.cmp(range_10, plot_file(11)) # Plot 12 uses the old range(10) figure and the new range(6) figure assert filecmp.cmp(range_10, plot_file('12_00')) assert filecmp.cmp(range_6, plot_file('12_01')) # Plot 13 shows close-figs in action assert filecmp.cmp(range_4, plot_file(13)) # Plot 14 has included source with open(pjoin(html_dir, 'some_plots.html'), 'rb') as fobj: html_contents = fobj.read() assert b'# Only a comment' in html_contents # check plot defined in external file. assert filecmp.cmp(range_4, pjoin(html_dir, 'range4.png')) assert filecmp.cmp(range_6, pjoin(html_dir, 'range6.png')) # check if figure caption made it into html file assert b'This is the caption for plot 15.' in html_contents
Example #23
Source File: run_tests.py From inaSpeechSegmenter with MIT License | 5 votes |
def test_batch(self): seg = Segmenter(vad_engine='sm') with tempfile.TemporaryDirectory() as tmpdirname: lout = [os.path.join(tmpdirname, '1.csv'), os.path.join(tmpdirname, '2.csv')] ret = seg.batch_process(['./media/musanmix.mp3', './media/musanmix.mp3'], lout) self.assertTrue(filecmp.cmp(lout[0], lout[1])) self.assertTrue(filecmp.cmp(lout[0], './media/musanmix-sm-gender.csv'))
Example #24
Source File: test_integration.py From pex with Apache License 2.0 | 5 votes |
def assert_reproducible_build(args): with temporary_dir() as td: pex1 = os.path.join(td, '1.pex') pex2 = os.path.join(td, '2.pex') # Note that we change the `PYTHONHASHSEED` to ensure that there are no issues resulting # from the random seed, such as data structures, as Tox sets this value by default. See # https://tox.readthedocs.io/en/latest/example/basic.html#special-handling-of-pythonhashseed. def create_pex(path, seed): result = run_pex_command(args + ['-o', path], env=make_env(PYTHONHASHSEED=seed)) result.assert_success() create_pex(pex1, seed=111) # We sleep to ensure that there is no non-reproducibility from timestamps or # anything that may depend on the system time. Note that we must sleep for at least # 2 seconds, because the zip format uses 2 second precision per section 4.4.6 of # https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT. safe_sleep(2) create_pex(pex2, seed=22222) # First explode the PEXes to compare file-by-file for easier debugging. with ZipFile(pex1) as zf1, ZipFile(pex2) as zf2: unzipped1 = os.path.join(td, "pex1") unzipped2 = os.path.join(td, "pex2") zf1.extractall(path=unzipped1) zf2.extractall(path=unzipped2) for member1, member2 in zip(sorted(zf1.namelist()), sorted(zf2.namelist())): assert filecmp.cmp( os.path.join(unzipped1, member1), os.path.join(unzipped2, member2), shallow=False ) # Then compare the original .pex files. This is the assertion we truly care about. assert filecmp.cmp(pex1, pex2, shallow=False)
Example #25
Source File: test_object_store_service.py From cloudbridge with MIT License | 5 votes |
def test_upload_download_bucket_content_with_large_file(self): # Creates a 6 Gig file in the temp directory, then uploads it to # Swift. Once uploaded, then downloads to a new file in the temp # directory and compares the two files to see if they match. temp_dir = tempfile.gettempdir() file_name = '6GigTest.tmp' six_gig_file = os.path.join(temp_dir, file_name) with open(six_gig_file, "wb") as out: out.truncate(6 * 1024 * 1024 * 1024) # 6 Gig... with cb_helpers.cleanup_action(lambda: os.remove(six_gig_file)): download_file = "{0}/cbtestfile-{1}".format(temp_dir, file_name) bucket_name = "cbtestbucketlargeobjs-{0}".format( helpers.get_uuid()) test_bucket = self.provider.storage.buckets.create(bucket_name) with cb_helpers.cleanup_action(lambda: test_bucket.delete()): test_obj = test_bucket.objects.create(file_name) with cb_helpers.cleanup_action(lambda: test_obj.delete()): file_uploaded = test_obj.upload_from_file(six_gig_file) self.assertTrue(file_uploaded, "Could not upload object?") with cb_helpers.cleanup_action( lambda: os.remove(download_file)): with open(download_file, 'wb') as f: test_obj.save_content(f) self.assertTrue( filecmp.cmp(six_gig_file, download_file), "Uploaded file != downloaded")
Example #26
Source File: botchecker.py From BotListBot with MIT License | 5 votes |
def download_profile_photo(self, bot: BotModel, photo_path): tmp_file = os.path.join(TMP_DIR, bot.username.replace('@', '') + '.jpg') photos = self.get_user_profile_photos(bot.chat_id).photos if photos: photo_size_object = photos[0][-1] await self.__photos_lock.acquire() try: try: self.download_media( photo_size_object, file_name=tmp_file, block=True ) except FloodWait as e: # TODO: as the error happens inside of the update worker, this won't work (yet) # Leaving it in as the default behavior should be to raise the FloodWait # when block=True log.debug(f"FloodWait for downloading media ({e.x})") if os.path.exists(tmp_file): try: similar = filecmp.cmp(tmp_file, photo_path, shallow=False) except FileNotFoundError: similar = False if not similar: shutil.copy(tmp_file, photo_path) finally: self.__photos_lock.release()
Example #27
Source File: test_s3_to_hive.py From airflow with Apache License 2.0 | 5 votes |
def _check_file_equality(fn_1, fn_2, ext): # gz files contain mtime and filename in the header that # causes filecmp to return False even if contents are identical # Hence decompress to test for equality if ext.lower() == '.gz': with GzipFile(fn_1, 'rb') as f_1, NamedTemporaryFile(mode='wb') as f_txt_1: with GzipFile(fn_2, 'rb') as f_2, NamedTemporaryFile(mode='wb') as f_txt_2: shutil.copyfileobj(f_1, f_txt_1) shutil.copyfileobj(f_2, f_txt_2) f_txt_1.flush() f_txt_2.flush() return filecmp.cmp(f_txt_1.name, f_txt_2.name, shallow=False) else: return filecmp.cmp(fn_1, fn_2, shallow=False)
Example #28
Source File: example_qubole.py From airflow with Apache License 2.0 | 5 votes |
def compare_result(**kwargs): """ Compares the results of two QuboleOperator tasks. :param kwargs: The context of the executed task. :type kwargs: dict :return: True if the files are the same, False otherwise. :rtype: bool """ ti = kwargs['ti'] qubole_result_1 = t1.get_results(ti) qubole_result_2 = t2.get_results(ti) return filecmp.cmp(qubole_result_1, qubole_result_2)
Example #29
Source File: test_filecmp.py From oss-ftp with MIT License | 5 votes |
def test_different(self): self.assertFalse(filecmp.cmp(self.name, self.name_diff), "Mismatched files compare as equal") self.assertFalse(filecmp.cmp(self.name, self.dir), "File and directory compare as equal")
Example #30
Source File: test_libzfs_core.py From pyzfs with Apache License 2.0 | 5 votes |
def test_recv_incremental(self): src1 = ZFSTest.pool.makeName("fs1@snap1") src2 = ZFSTest.pool.makeName("fs1@snap2") dst1 = ZFSTest.pool.makeName("fs2/received-2@snap1") dst2 = ZFSTest.pool.makeName("fs2/received-2@snap2") lzc.lzc_snapshot([src1]) with temp_file_in_fs(ZFSTest.pool.makeName("fs1")) as name: lzc.lzc_snapshot([src2]) with tempfile.TemporaryFile(suffix='.ztream') as stream: lzc.lzc_send(src1, None, stream.fileno()) stream.seek(0) lzc.lzc_receive(dst1, stream.fileno()) with tempfile.TemporaryFile(suffix='.ztream') as stream: lzc.lzc_send(src2, src1, stream.fileno()) stream.seek(0) lzc.lzc_receive(dst2, stream.fileno()) name = os.path.basename(name) with zfs_mount(src2) as mnt1, zfs_mount(dst2) as mnt2: self.assertTrue( filecmp.cmp(os.path.join(mnt1, name), os.path.join(mnt2, name), False)) # This test case fails unless unless a patch from # https://clusterhq.atlassian.net/browse/ZFS-20 # is applied to libzfs_core, otherwise it succeeds.