|
5 | 5 | .. code-block:: python |
6 | 6 |
|
7 | 7 | # 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 |
10 | 11 | """ |
11 | 12 |
|
12 | 13 | # ############################################################################# |
@@ -76,12 +77,37 @@ def test_not_git_repo(self): |
76 | 77 | output_path=tmpdirname, |
77 | 78 | strict=True, |
78 | 79 | ) |
79 | | - if cli_result.exception is not None: |
80 | | - e = cli_result.exception |
81 | | - logger.debug(format_exception(type(e), e, e.__traceback__)) |
82 | 80 |
|
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 | + |
84 | 101 | 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 | + ) |
85 | 111 |
|
86 | 112 | # restore name |
87 | 113 | git_dir_tmp.replace(git_dir) |
|
0 commit comments