brodriguez8774 / django-expanded-test-cases

Extends the existing Django TestCase class with extra functionality.
MIT License
2 stars 0 forks source link

AssertContent Subsection Coloring #14

Open brodriguez8774 opened 2 years ago

brodriguez8774 commented 2 years ago

When using any form of AssertContent with the subsection args ( content_starts_after / content_ends_before ), it would be nice if there was some sort of coloring for the content "debug print" output.

Initial idea was to display the full response content, but then change coloring:

Such behavior would be incredibly useful for testing responses with large amounts of page output, but only very limited sections actually being searched.

Furthermore, this color output should probably be toggle-able as a setting, in case there are ever bugs with parsing content values. That way, there is always a fallback of "this is for sure what the full, literal page output really is".

brodriguez8774 commented 2 years ago

Original attempt at this logic can be seen on the current content_subsection_coloring branch.

Major hurdle was trying to check the "section to trim" against the actual rendered template HTML.

Basically, in all other checks, we simply strip out all possible whitespace and then do our checks. Then if needed, we display a non-stripped version of the HTML to console.

However, this logic does not seem feasible in this "content subsection coloring" logic. As we need the original whitespace-included value for inevitable console display. Since that's the entire point of this logic. But if we do a match with the standard trimmed whitespace, then we either lose our display fallback.

This is probably do-able but I honestly got pretty confused on the content_subsection_coloring branch, before I realized what the actual issue was. So there's probably a good number of changes/debug statements that are unnecessary. Probably best to only use the branch as reference, and restart writing this from scratch off of current development.