Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test possibly checking for wrong value #48

Open
JonathanHolvey opened this issue Dec 26, 2016 · 0 comments
Open

Unit test possibly checking for wrong value #48

JonathanHolvey opened this issue Dec 26, 2016 · 0 comments

Comments

@JonathanHolvey
Copy link

While running the unit tests on a modified branch of Python Patch, I've been trying to debug some of the failed tests I'm seeing. The first of these, test_multiline_false_on_other_file() would appear to be working correctly with the master branch, and failing with my branch, however, by manually checking the test patch and target files, I believe that the wrong value is being checked for.

The test uses the method assertFalse() on the return value of can_patch(), which in turn calls _match_file_hunks(). The False value here is coming from _match_file_hunks() when checking hunk 1 of the patch 01uni_multi.patch aginst updatedlg.cpp.

This is the hunk in question:

@@ -94,11 +94,13 @@
     lst->InsertColumn(1, _("Version"));
     lst->InsertColumn(2, _("Installed"));
     lst->InsertColumn(3, _("Size"), wxLIST_FORMAT_RIGHT);
+    lst->InsertColumn(4, _("Rev"));
 
-    lst->SetColumnWidth(0, lst->GetSize().x - (64 * 3) - 2); // 1st column takes all remaining space
+    lst->SetColumnWidth(0, lst->GetSize().x - (64 * 3 + 40) - 6 ); // 1st column takes all remaining space
     lst->SetColumnWidth(1, 64);
     lst->SetColumnWidth(2, 64);
     lst->SetColumnWidth(3, 64);
+    lst->SetColumnWidth(4, 40);
 }
 
 void UpdateDlg::AddRecordToList(UpdateRec* rec)

and here is the relevant section of updatedlg.cpp, starting from line 94:

    lst->InsertColumn(1, _("Version"));
    lst->InsertColumn(2, _("Installed"));
    lst->InsertColumn(3, _("Size"), wxLIST_FORMAT_RIGHT);

    lst->SetColumnWidth(0, lst->GetSize().x - (64 * 3) - 2); // 1st column takes all remaining space
    lst->SetColumnWidth(1, 64);
    lst->SetColumnWidth(2, 64);
    lst->SetColumnWidth(3, 64);
}

void UpdateDlg::AddRecordToList(UpdateRec* rec)

Checking still deeper I found that when it fails, _match_file_hunks() is in fact making the following comparison, between line 97 of the target file and the fourth line of the patch hunk, rather than the fifth:

b'' != b'    lst->InsertColumn(4, _("Rev"));'

As far as I can tell, a bug somewhere in patch.py is causing an addition line in the patch to be compared with the target file, and the unit test checking for this has been set up incorrectly, since the patch seems to be valid for the files it modifies.

Can anyone throw some light on to what exactly test_multiline_false_on_other_file() is intended to check? Am I correct in my deductions above, or have I overlooked something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant