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

Improve test coverage, docs, and .gitignore #3323

Merged
merged 3 commits into from
Jun 16, 2024

Conversation

boxydog
Copy link
Contributor

@boxydog boxydog commented Jun 1, 2024

  • Ensured tests pass and (if applicable) updated functional test output
  • Conformed to code style guidelines by running appropriate linting tools

I wanted to see if I could improve test coverage. __init__.py was a file with a big coverage gap, so I wrote some tests to invoke main (not previously invoked). If this is acceptable, we can invoke main with different arguments to cover different pieces.

I must admit, I'm a bit disappointed to only cover 24 additional lines, but they are probably important lines (making sure main still runs). See coverage below.

As I was working, I also wrote a bit in the docs, and excluded signals.py from test coverage, since it's deprecated.

  • BEFORE:
Name                                  Stmts   Miss  Cover
---------------------------------------------------------
pelican/__init__.py                     301    142    53%
pelican/__main__.py                       3      0   100%
pelican/cache.py                         68     13    81%
pelican/contents.py                     345     15    96%
pelican/generators.py                   491     33    93%
pelican/log.py                           84     13    85%
pelican/paginator.py                     92     13    86%
pelican/plugins/_utils.py                79     16    80%
pelican/plugins/signals.py               31      0   100%
pelican/readers.py                      409     17    96%
pelican/rstdirectives.py                 47      3    94%
pelican/server.py                        92     39    58%
pelican/settings.py                     248     54    78%
pelican/signals.py                        1      1     0%
pelican/tools/__init__.py                 0      0   100%
pelican/tools/pelican_import.py         636    232    64%
pelican/tools/pelican_quickstart.py     180    180     0%
pelican/tools/pelican_themes.py         154    154     0%
pelican/urlwrappers.py                   89      9    90%
pelican/utils.py                        445     68    85%
pelican/writers.py                      124      6    95%
---------------------------------------------------------
TOTAL                                  3919   1008    74%
  • AFTER:
Name                                  Stmts   Miss  Cover
---------------------------------------------------------
pelican/__init__.py                     301    120    60%
pelican/__main__.py                       3      0   100%
pelican/cache.py                         68     13    81%
pelican/contents.py                     345     15    96%
pelican/generators.py                   491     33    93%
pelican/log.py                           84     12    86%
pelican/paginator.py                     92     13    86%
pelican/plugins/_utils.py                79     16    80%
pelican/plugins/signals.py               31      0   100%
pelican/readers.py                      409     17    96%
pelican/rstdirectives.py                 47      3    94%
pelican/server.py                        92     39    58%
pelican/settings.py                     248     54    78%
pelican/tools/__init__.py                 0      0   100%
pelican/tools/pelican_import.py         636    232    64%
pelican/tools/pelican_quickstart.py     180    180     0%
pelican/tools/pelican_themes.py         154    154     0%
pelican/urlwrappers.py                   89      9    90%
pelican/utils.py                        445     68    85%
pelican/writers.py                      124      6    95%
---------------------------------------------------------
TOTAL                                  3918    984    75%

@boxydog
Copy link
Contributor Author

boxydog commented Jun 1, 2024

The test fails on windows in a way I don't understand:

E AssertionError: 'Processed 1 article' not found in 'Done: Processed \x1b[1;36m1\x1b[0m article, \x1b[1;36m0\x1b[0m drafts, \x1b[1;36m0\x1b[0m hidden articles, \x1b[1;36m0\x1b[0m pages, \x1b[1;36m0\x1b[0m hidden pages\nand \x1b[1;36m0\x1b[0m draft pages in \x1b[1;36m0.11\x1b[0m seconds.\n\x1b[32m⠋\x1b[0m Generating...'

No idea what those crazy control characters are. Colors? But the console.print should print a very plain string (link).

I could change the assert to be simpler I guess, but computers are so irksome. Why doesn't this work?

@boxydog
Copy link
Contributor Author

boxydog commented Jun 1, 2024

Ah, the rich console highlights things, like numbers, on a sufficiently fancy console. I tried to disable it in the test, but it didn't work (yet?)

@boxydog
Copy link
Contributor Author

boxydog commented Jun 1, 2024

That worked.

@justinmayer
Copy link
Member

Thank you for these enhancements, @boxydog. I am traveling this week but should be able to take a look next week.

In the interim, is there any input from other folks? cc: @getpelican/reviewers

Also includes a change that causes this command to return a failing
status when coverage drops below its current value of 74.8%.
@justinmayer justinmayer changed the title Improve test coverage, docs, and .gitignore Improve test coverage, docs, and .gitignore Jun 16, 2024
Copy link
Member

@justinmayer justinmayer left a comment

Choose a reason for hiding this comment

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

Many thanks for these improvements, @boxydog. Any follow-on PRs that further enhance our test coverage would also be much appreciated! 💫

@justinmayer justinmayer merged commit d83c502 into getpelican:master Jun 16, 2024
15 checks passed
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.

2 participants