Skip to content

Commit

Permalink
Fix test_towncrier_config_section_missing for Win
Browse files Browse the repository at this point in the history
This test was failing with the following error under Windows:

    OSError: [WinError 1] Incorrect function: 'nul'
  • Loading branch information
webknjaz committed Sep 26, 2023
1 parent c9a2ed6 commit 729b600
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tests/_towncrier_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Towncrier config reader tests."""


import os
from pathlib import Path
from typing import Union

Expand All @@ -11,12 +10,21 @@
from ._compat import TowncrierConfigError


def test_towncrier_config_section_missing(tmp_path: Path) -> None:
def test_towncrier_config_section_missing(
monkeypatch: pytest.MonkeyPatch,
tmp_path: Path,
) -> None:
"""Test config file without Towncrier section raises an error."""
tmp_working_dir_path = tmp_path / 'working-directory'
tmp_working_dir_path.mkdir()
empty_config_file = Path('arbitrary-config.toml')
(tmp_working_dir_path / empty_config_file).touch()
monkeypatch.chdir(tmp_working_dir_path)

expected_error_msg = r'^No \[tool\.towncrier\] section\.$'

with pytest.raises(TowncrierConfigError, match=expected_error_msg):
get_towncrier_config(tmp_path, Path(os.devnull))
get_towncrier_config(tmp_path, empty_config_file)


@pytest.mark.parametrize(
Expand Down

0 comments on commit 729b600

Please sign in to comment.