@@ -50,10 +50,28 @@ def test_not_badge(self):
5050
5151
5252class TestAddBadge :
53+ def test_no_readme (self , bare_dir : Path , capfd : pytest .CaptureFixture [str ]):
54+ # Act
55+ with change_cwd (bare_dir ), PyprojectTOMLManager ():
56+ add_badge (
57+ Badge (
58+ markdown = "" ,
59+ )
60+ )
61+
62+ # Assert (that the badge markdown is printed)
63+ out , err = capfd .readouterr ()
64+ assert not err
65+ assert out == (
66+ "✔ Writing 'README.md'.\n "
67+ "☐ Populate 'README.md' to help users understand the project.\n "
68+ "✔ Adding Licence badge to 'README.md'.\n "
69+ )
70+
5371 def test_not_markdown (self , bare_dir : Path , capfd : pytest .CaptureFixture [str ]):
5472 # Arrange
5573 path = bare_dir / "README.foo"
56- path .touch ( )
74+ path .write_text ( "# Header \n " )
5775
5876 # Act
5977 with change_cwd (bare_dir ), PyprojectTOMLManager ():
@@ -67,15 +85,14 @@ def test_not_markdown(self, bare_dir: Path, capfd: pytest.CaptureFixture[str]):
6785 out , err = capfd .readouterr ()
6886 assert not err
6987 assert out == (
70- "⚠ README file not found, printing badge markdown instead...\n "
88+ "⚠ No Markdown-based README file found, printing badge markdown instead...\n "
7189 "\n "
7290 )
7391
7492 def test_empty (self , bare_dir : Path , capfd : pytest .CaptureFixture [str ]):
7593 # Arrange
7694 path = bare_dir / "README.md"
77- path .write_text ("""\
78- """ )
95+ path .write_text ("" )
7996
8097 # Act
8198 with change_cwd (bare_dir ), PyprojectTOMLManager ():
@@ -89,12 +106,18 @@ def test_empty(self, bare_dir: Path, capfd: pytest.CaptureFixture[str]):
89106 assert (
90107 (bare_dir / "README.md" ).read_text ()
91108 == """\
109+ # test_empty0
110+
92111
93112"""
94113 )
95114 out , err = capfd .readouterr ()
96115 assert not err
97- assert out == "✔ Adding Licence badge to 'README.md'.\n "
116+ assert out == (
117+ "✔ Writing 'README.md'.\n "
118+ "☐ Populate 'README.md' to help users understand the project.\n "
119+ "✔ Adding Licence badge to 'README.md'.\n "
120+ )
98121
99122 def test_only_newline (self , bare_dir : Path ):
100123 # Arrange
@@ -115,6 +138,8 @@ def test_only_newline(self, bare_dir: Path):
115138 assert (
116139 (bare_dir / "README.md" ).read_text ()
117140 == """\
141+ # test_only_newline0
142+
118143
119144"""
120145 )
0 commit comments