|
3 | 3 |
|
4 | 4 | import os
|
5 | 5 | import tempfile
|
| 6 | +import textwrap |
6 | 7 |
|
7 | 8 | from datetime import date
|
8 | 9 | from pathlib import Path
|
@@ -1769,3 +1770,83 @@ def test_no_ignore_configured(self, runner):
|
1769 | 1770 | _main, ["--draft", "--date", "01-01-2001", "--version", "1.0.0"]
|
1770 | 1771 | )
|
1771 | 1772 | self.assertEqual(0, result.exit_code, result.output)
|
| 1773 | + |
| 1774 | + @with_project( |
| 1775 | + config=""" |
| 1776 | + [tool.towncrier] |
| 1777 | + package = "foo" |
| 1778 | + title_format = "{version} - {project_date}" |
| 1779 | +
|
| 1780 | + [[tool.towncrier.type]] |
| 1781 | + directory = "feature" |
| 1782 | + name = "Feature" |
| 1783 | + # showcontent is not defined in TOML |
| 1784 | + """ |
| 1785 | + ) |
| 1786 | + def test_showcontent_default_toml_array(self, runner): |
| 1787 | + """ |
| 1788 | + When configuring custom fragment types with a TOML array |
| 1789 | + a missing `showcontent` defaults to `true`. |
| 1790 | + """ |
| 1791 | + write("foo/newsfragments/+new_feature.feature.md", "An exciting new feature!") |
| 1792 | + result = runner.invoke(_main, ["--date", "01-01-2001", "--version", "1.0.0"]) |
| 1793 | + news = read("NEWS.rst") |
| 1794 | + expected = textwrap.dedent( |
| 1795 | + """\ |
| 1796 | + 1.0.0 - 01-01-2001 |
| 1797 | + ================== |
| 1798 | +
|
| 1799 | + Feature |
| 1800 | + ------- |
| 1801 | +
|
| 1802 | + - An exciting new feature! |
| 1803 | + """ |
| 1804 | + ) |
| 1805 | + self.assertEqual(0, result.exit_code, result.output) |
| 1806 | + self.assertEqual(expected, news, news) |
| 1807 | + |
| 1808 | + @with_project( |
| 1809 | + config=""" |
| 1810 | + [tool.towncrier] |
| 1811 | + package = "foo" |
| 1812 | + title_format = "{version} - {project_date}" |
| 1813 | +
|
| 1814 | + [[tool.towncrier.type]] |
| 1815 | + # The `FRAGMENT.feature` files have no explicit |
| 1816 | + # `directory` configuration. |
| 1817 | + name = "Feature" |
| 1818 | +
|
| 1819 | + [[tool.towncrier.type]] |
| 1820 | + directory = "deps" |
| 1821 | + name = "Dependency" |
| 1822 | + """ |
| 1823 | + ) |
| 1824 | + def test_directory_default_toml_array(self, runner): |
| 1825 | + """ |
| 1826 | + When configuring custom fragment types with a TOML array |
| 1827 | + the `directory` key is optional. Its value is inferred |
| 1828 | + from the `name` configuration. |
| 1829 | + """ |
| 1830 | + write("foo/newsfragments/+new_feature.feature.md", "An exciting new feature!") |
| 1831 | + write("foo/newsfragments/+bump_deps.deps.md", "We bumped our dependencies.") |
| 1832 | + result = runner.invoke(_main, ["--date", "01-01-2001", "--version", "1.0.0"]) |
| 1833 | + news = read("NEWS.rst") |
| 1834 | + expected = textwrap.dedent( |
| 1835 | + """\ |
| 1836 | + 1.0.0 - 01-01-2001 |
| 1837 | + ================== |
| 1838 | +
|
| 1839 | + Feature |
| 1840 | + ------- |
| 1841 | +
|
| 1842 | + - An exciting new feature! |
| 1843 | +
|
| 1844 | +
|
| 1845 | + Dependency |
| 1846 | + ---------- |
| 1847 | +
|
| 1848 | + - We bumped our dependencies. |
| 1849 | + """ |
| 1850 | + ) |
| 1851 | + self.assertEqual(0, result.exit_code, result.output) |
| 1852 | + self.assertEqual(expected, news, news) |
0 commit comments