Skip to content

Commit 5e017b6

Browse files
committed
Improve no git tests
1 parent cda42d2 commit 5e017b6

1 file changed

Lines changed: 32 additions & 6 deletions

File tree

tests/test_build_no_git.py

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
.. code-block:: python
66
77
# for whole test
8-
python -m unittest tests.test_build
9-
8+
python -m unittest tests.test_build_no_git
9+
# for specific test
10+
python -m unittest tests.test_build_no_git.TestBuildRssNoGit.test_not_git_repo_without_option
1011
"""
1112

1213
# #############################################################################
@@ -76,12 +77,37 @@ def test_not_git_repo(self):
7677
output_path=tmpdirname,
7778
strict=True,
7879
)
79-
if cli_result.exception is not None:
80-
e = cli_result.exception
81-
logger.debug(format_exception(type(e), e, e.__traceback__))
8280

83-
self.assertEqual(cli_result.exit_code, 1)
81+
self.assertIsNone(cli_result.exception)
82+
self.assertEqual(cli_result.exit_code, 0, cli_result)
83+
84+
# restore name
85+
git_dir_tmp.replace(git_dir)
86+
87+
def test_not_git_repo_without_option(self):
88+
# temporarily rename the git folder to fake a non-git repo
89+
git_dir = Path(".git")
90+
git_dir_tmp = git_dir.with_name("_git")
91+
git_dir.replace(git_dir_tmp)
92+
93+
with tempfile.TemporaryDirectory() as tmpdirname:
94+
cli_result = self.build_docs_setup(
95+
testproject_path="docs",
96+
mkdocs_yml_filepath=Path("tests/fixtures/mkdocs_complete.yml"),
97+
output_path=tmpdirname,
98+
strict=True,
99+
)
100+
84101
self.assertIsNotNone(cli_result.exception)
102+
self.assertEqual(
103+
cli_result.exit_code,
104+
1,
105+
format_exception(
106+
type(cli_result.exception),
107+
cli_result.exception,
108+
cli_result.exception.__traceback__,
109+
),
110+
)
85111

86112
# restore name
87113
git_dir_tmp.replace(git_dir)

0 commit comments

Comments
 (0)