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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added html parsing tools for testing #1128

Merged
merged 2 commits into from
Mar 15, 2021

Conversation

smithdc1
Copy link
Member

This allows the expected html to be stored in an HTML file. Tests can then assert the layout of the whole form.

I've been using this method with the bootstrap5 template pack and have been enjoying working in this way.
I'd like to introduce this here as I think it is helpful generally, I find that tests are more readable as you can see all of the output. It's also then easier to have a discussion about if there is an issue as you can point to the line in the html code that is in question.

More specifically I think it will be helpful to prove the optgroup filter and upcoming changes are ok as we'll clearly be able to see the changes that happen (hopefully none 馃 ) which I think could be missed with the current approach.

This allows the expected html to be stored in an HTML file. Tests can then assert the layout of the whole form.
@codecov-io
Copy link

codecov-io commented Mar 14, 2021

Codecov Report

Merging #1128 (de5228b) into master (56a423e) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1128      +/-   ##
==========================================
+ Coverage   97.23%   97.24%   +0.01%     
==========================================
  Files          23       23              
  Lines        2816     2836      +20     
  Branches      243      243              
==========================================
+ Hits         2738     2758      +20     
  Misses         38       38              
  Partials       40       40              
Flag Coverage 螖
unittests 97.21% <100.00%> (+0.01%) 猬嗭笍

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage 螖
crispy_forms/tests/test_utils.py 100.00% <100.00%> (酶)
crispy_forms/tests/utils.py 100.00% <100.00%> (酶)

Continue to review full report at Codecov.

Legend - Click here to learn more
螖 = absolute <relative> (impact), 酶 = not affected, ? = missing data
Powered by Codecov. Last update 56a423e...de5228b. Read the comment docs.

Copy link
Collaborator

@carltongibson carltongibson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @smithdc1 鈥斅營 think this is a good move. Having the HTML as strings in the tests has been a pain point 鈮坒orever 鈥斅爏o attacking that has to be a win. 馃憤

@smithdc1
Copy link
Member Author

Thanks Carlton!

@smithdc1 smithdc1 merged commit ed8c518 into django-crispy-forms:master Mar 15, 2021
@smithdc1 smithdc1 deleted the render_form branch March 15, 2021 21:23
@smithdc1 smithdc1 added this to the Next Release milestone Mar 16, 2021
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

Successfully merging this pull request may close these issues.

None yet

3 participants