#706 Refactor markdown template to make it easier to read#709
#706 Refactor markdown template to make it easier to read#709adiroiban merged 7 commits intotwisted:trunkfrom
Conversation
- improve logical flow - add indentation - detailed comments - generally made it easier to understand, extend, and customize.
- Adapt CliRunner for different Click library versions to correctly handle error messages.
|
Not sure if this is something you'd want to do on a project level but I wanted to silence the encoding warnings to be able to parse the output diff --git a/noxfile.py b/noxfile.py
index 494085c..92d6359 100644
--- a/noxfile.py
+++ b/noxfile.py
@@ -21,6 +21,7 @@ def pre_commit(session: nox.Session) -> None:
@nox.session(python=["pypy3.10", "3.9", "3.10", "3.11", "3.12", "3.13"])
def tests(session: nox.Session) -> None:
session.env["PYTHONWARNDEFAULTENCODING"] = "1"
+ session.env['PYTHONWARNINGS'] = 'ignore::EncodingWarning'
session.install("Twisted", "coverage[toml]")
posargs = list(session.posargs) |
- allows github to display them with the right syntax highlighting
I think that the idea with the encoding warnings was to observer which code triggered the warnings and fix the code. Are these warnings from dependencies ? Maybe we can send fixes upstream |
| ) | ||
|
|
||
| result = runner.invoke(_main, ["--date", "01-01-2001"], catch_exceptions=False) | ||
| result = runner.invoke( |
There was a problem hiding this comment.
just asking? Why do we need --yes here ... and why it wasn't required in the previous version of the code?
There was a problem hiding this comment.
if not you get the following test failures
Example:
towncrier.test.test_build.TestCli.test_markdown_no_name_title
===============================================================================
[FAIL]
Traceback (most recent call last):
File "/home/runner/work/towncrier/towncrier/.nox/tests-3-10/lib/python3.10/site-packages/towncrier/test/helpers.py", line 96, in test
return fn(*args, runner=runner, **kw)
File "/home/runner/work/towncrier/towncrier/.nox/tests-3-10/lib/python3.10/site-packages/towncrier/test/test_build.py", line 1797, in test_showcontent_default_toml_array
self.assertEqual(0, result.exit_code, result.output)
File "/home/runner/work/towncrier/towncrier/.nox/tests-3-10/lib/python3.10/site-packages/twisted/trial/_synctest.py", line 444, in assertEqual
super().assertEqual(first, second, msg)
File "/opt/hostedtoolcache/Python/3.10.17/x64/lib/python3.10/unittest/case.py", line 845, in assertEqual
assertion_func(first, second, msg=msg)
File "/opt/hostedtoolcache/Python/3.10.17/x64/lib/python3.10/unittest/case.py", line 838, in _baseAssertEqual
raise self.failureException(msg)
twisted.trial.unittest.FailTest: 0 != 1 : Loading template...
Finding news fragments...
Rendering news fragments...
Writing to newsfile...
Staging newsfile...
I want to remove the following files:
/tmp/tmpm09_krm5/foo/newsfragments/+new_feature.feature.md
Is it okay if I remove those files? [Y/n]:Aborted!
There was a problem hiding this comment.
Did you need me to do anything more to close this out?
| try: | ||
| runner = CliRunner(mix_stderr=False) | ||
| except TypeError: | ||
| # Fallback for older Click versions (or unexpected signature) |
There was a problem hiding this comment.
Which version of Click is targeted were ?
If we plan to support an older version of click we should add an explicit test run using that version of Click
I think that we should declare a minimum version of click
Lines 31 to 33 in 2707779
I think that the idea was that towncrier is a dev tool, so users will always run it in a separte environment and will be able to use latest deps
Somehow, it looks like our code coverage checks have not failed here...as we don't report coverage for the test code itself ...
But I think that we should.... but in a separate ticket.
There was a problem hiding this comment.
Click 8.2 removed the mix_stderr option - see Click Changelog
This results in the following test failures
Example:
towncrier.test.test_build.TestCli.test_showcontent_default_toml_array
===============================================================================
Error:
Traceback (most recent call last):
File "/home/runner/work/towncrier/towncrier/.nox/tests-3-10/lib/python3.10/site-packages/towncrier/test/test_check.py", line 302, in test_none_stdout_encoding_works
runner = CliRunner(mix_stderr=False)
builtins.TypeError: CliRunner.__init__() got an unexpected keyword argument 'mix_stderr'
I thought handling it this way would give you the most flexibility
There was a problem hiding this comment.
Thanks. I think that we need to define a minimum vesion of click that we support and make sure that we execute tests using that version.
but it can be done for a separate ticket. I have created #710
There was a problem hiding this comment.
I wasn't clear if this is something you wanted me to do now or define for future dev?
Co-authored-by: Firas AlShafei <[email protected]>
|
Sorry for the delay. I have merged this now. Thanks! |
Description
Template
Update the default markdown template to use standard jinja formatting
Fixes #706
CI
--yesflag to build tests to prevent interactive prompt failuresChecklist
src/towncrier/newsfragments/. Briefly describe yourchanges, with information useful to end users. Your change will be included in the public release notes.
docs/tutorial.rstis still up-to-date.docs/cli.rstreflects those changes.docs/configuration.rstreflects those changes.