diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index caaf0034..491236b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,8 @@ jobs: runs-on: ubuntu-latest - name: macOS runs-on: macos-latest + - name: Windows + runs-on: windows-latest python: - name: CPython 2.7 tox: py27 @@ -46,6 +48,14 @@ jobs: task: - name: Test tox: tests + exclude: + # Twisted and thus trial do not work on Windows with CPython 3.9. + # This will be fixed with the next release. + # https://twistedmatrix.com/trac/ticket/10027 + - python: + tox: py39 + os: + name: Windows steps: - uses: actions/checkout@v2 diff --git a/src/towncrier/_writer.py b/src/towncrier/_writer.py index 65c9324e..1a2c31dc 100644 --- a/src/towncrier/_writer.py +++ b/src/towncrier/_writer.py @@ -8,6 +8,7 @@ from __future__ import absolute_import, division +import io import os @@ -21,8 +22,8 @@ def append_to_newsfile( if not os.path.exists(news_file): existing_content = u"" else: - with open(news_file, "rb") as f: - existing_content = f.read().decode("utf8") + with io.open(news_file, "r", encoding="utf8") as f: + existing_content = f.read() existing_content = existing_content.split(start_line, 1) else: existing_content = [u""] diff --git a/src/towncrier/check.py b/src/towncrier/check.py index cdd06d6b..3979fa45 100644 --- a/src/towncrier/check.py +++ b/src/towncrier/check.py @@ -48,12 +48,10 @@ def __main(comparewith, directory, config): click.echo("On trunk, or no diffs, so no newsfragment required.") sys.exit(0) - files = set( - map( - lambda x: os.path.join(base_directory, x), - files_changed.strip().split(os.linesep), - ) - ) + files = { + os.path.normpath(os.path.join(base_directory, path)) + for path in files_changed.strip().splitlines() + } click.echo("Looking at these files:") click.echo("----") @@ -72,14 +70,15 @@ def __main(comparewith, directory, config): ) fragment_directory = "newsfragments" - fragments = set( - find_fragments( + fragments = { + os.path.normpath(path) + for path in find_fragments( fragment_base_directory, config["sections"], fragment_directory, config["types"], )[1] - ) + } fragments_in_branch = fragments & files if not fragments_in_branch: diff --git a/src/towncrier/newsfragments/287.misc.rst b/src/towncrier/newsfragments/287.misc.rst new file mode 100644 index 00000000..e69de29b diff --git a/src/towncrier/test/test_settings.py b/src/towncrier/test/test_settings.py index 9fbc987f..6565ca07 100644 --- a/src/towncrier/test/test_settings.py +++ b/src/towncrier/test/test_settings.py @@ -169,7 +169,10 @@ def test_missing_template(self): load_config(temp) self.assertEqual( - str(e.exception), "The template file '%s/foo.rst' does not exist." % (temp,) + str(e.exception), + "The template file '{}' does not exist.".format( + os.path.normpath(os.path.join(temp, "foo.rst")), + ) ) def test_missing_template_in_towncrier(self): diff --git a/tox.ini b/tox.ini index 8c605254..b4f0ad24 100644 --- a/tox.ini +++ b/tox.ini @@ -35,7 +35,9 @@ commands = coverage --version {envbindir}/trial --version coverage erase - coverage run -p {envbindir}/trial {posargs:towncrier} + # `coverage run` tries to act like Python so we use `--module` instead of + # specifying the entry point script in `{envbindir}`. + coverage run -p --module twisted.trial {posargs:towncrier} coverage combine -a [testenv:cov-report]