Example #1
0
def test_dot_changes_compare_non_existing(monkeypatch, dot_changes1):
    monkeypatch.setattr(Config.general, 'new_file', True)
    difference = dot_changes1.compare(
        NonExistingFile('/nonexisting', dot_changes1))
    output_text(difference, print_func=print)
    assert difference.source2 == '/nonexisting'
    assert difference.details[-1].source2 == '/dev/null'
Example #2
0
 def comparisons(self, other):
     my_members = self.get_members()
     other_members = other.get_members()
     for name in sorted(my_members.keys() & other_members.keys()):
         yield my_members.pop(name), other_members.pop(name), NO_COMMENT
     for my_name, other_name, score in diffoscope.comparators.perform_fuzzy_matching(
             my_members, other_members):
         comment = 'Files similar despite different names (difference score: %d)' % score
         yield my_members.pop(my_name), other_members.pop(
             other_name), comment
     if Config.general.new_file:
         for my_name in my_members.keys() - other_members.keys():
             my_file = my_members[my_name]
             yield my_file, NonExistingFile('/dev/null',
                                            my_file), NO_COMMENT
         for other_name in other_members.keys() - my_members.keys():
             other_file = other_members[other_name]
             yield NonExistingFile('/dev/null',
                                   other_file), other_file, NO_COMMENT
Example #3
0
 def comparisons(self, other):
     my_members = self.get_members()
     my_reminders = OrderedDict()
     other_members = other.get_members()
     # keep it sorted like my members
     while my_members:
         my_member_name, my_member = my_members.popitem(last=False)
         if my_member_name in other_members:
             yield my_member, other_members.pop(my_member_name), NO_COMMENT
         else:
             my_reminders[my_member_name] = my_member
     my_members = my_reminders
     for my_name, other_name, score in diffoscope.comparators.perform_fuzzy_matching(my_members, other_members):
         comment = 'Files similar despite different names (difference score: %d)' % score
         yield my_members.pop(my_name), other_members.pop(other_name), comment
     if Config.general.new_file:
         for my_member in my_members.values():
             yield my_member, NonExistingFile('/dev/null', my_member), NO_COMMENT
         for other_member in other_members.values():
             yield NonExistingFile('/dev/null', other_member), other_member, NO_COMMENT
Example #4
0
def test_obj_compare_non_existing(monkeypatch, obj1):
    monkeypatch.setattr(Config, 'new_file', True)
    difference = obj1.compare(NonExistingFile('/nonexisting', obj1))
    assert difference.source2 == '/nonexisting'
Example #5
0
def test_compare_non_existing(monkeypatch, bzip1):
    monkeypatch.setattr(Config, 'new_file', True)
    difference = bzip1.compare(NonExistingFile('/nonexisting', bzip1))
    assert difference.source2 == '/nonexisting'
    assert difference.details[-1].source2 == '/dev/null'
Example #6
0
def test_no_permissions_dir_in_tarball(monkeypatch, no_permissions_tar):
    # We want to make sure OSError is not raised.
    # Comparing with non-existing file makes it easy to make sure all files are unpacked
    monkeypatch.setattr(Config, 'new_file', True)
    no_permissions_tar.compare(
        NonExistingFile('/nonexistent', no_permissions_tar))
Example #7
0
def test_compare_non_existing(monkeypatch, pdf1):
    monkeypatch.setattr(Config, 'new_file', True)
    difference = pdf1.compare(NonExistingFile('/nonexisting', pdf1))
    assert difference.source2 == '/nonexisting'
    assert len(difference.details) > 0
Example #8
0
def test_compare_non_existing(monkeypatch, sqlite3db1):
    monkeypatch.setattr(Config.general, 'new_file', True)
    difference = sqlite3db1.compare(NonExistingFile('/nonexisting', sqlite3db1))
    assert difference.source2 == '/nonexisting'
    assert len(difference.details) > 0
Example #9
0
def test_compare_non_existing_with_xxd(binary1):
    difference = binary1.compare_bytes(NonExistingFile('/nonexisting',
                                                       binary1))
    assert difference.source2 == '/nonexisting'
Example #10
0
def test_compare_two_nonexisting_files():
    file1 = NonExistingFile('/nonexisting1')
    file2 = NonExistingFile('/nonexisting2')
    difference = file1.compare(file2)
    assert 'non-existing' in difference.comment
Example #11
0
 def get_member(self, member_name):
     return NonExistingFile('/dev/null')
Example #12
0
def test_compare_non_existing(monkeypatch, ascii1):
    monkeypatch.setattr(Config.general, 'new_file', True)
    difference = ascii1.compare(NonExistingFile('/nonexisting', ascii1))
    assert difference.source2 == '/nonexisting'