diff --git a/pyproject.toml b/pyproject.toml index 8a891b49..bdc37b27 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,8 +35,10 @@ include = ["theHarvester*"] "*" = ["*.txt", "*.yaml"] [tool.pytest.ini_options] -minversion = "7.1.1" -addopts = "--no-header --asyncio-mode=auto" +minversion = "8.3.3" +asyncio_mode = "auto" +asyncio_default_fixture_loop_scope = "function" +addopts = "--no-header" testpaths = [ "tests", "tests/discovery/", diff --git a/tests/discovery/test_githubcode.py b/tests/discovery/test_githubcode.py index ff6ac5f5..cf5f5e02 100644 --- a/tests/discovery/test_githubcode.py +++ b/tests/discovery/test_githubcode.py @@ -77,7 +77,6 @@ async def test_last_page(self) -> None: Core.github_key = MagicMock(return_value="lol") test_class_instance = githubcode.SearchGithubCode(word="test", limit=500) test_result = githubcode.SuccessResult(list(), None, None) - assert None is await test_class_instance.next_page_or_end(test_result) - + assert await test_class_instance.next_page_or_end(test_result) is None if __name__ == "__main__": pytest.main() diff --git a/theHarvester/discovery/githubcode.py b/theHarvester/discovery/githubcode.py index 0779dbb4..329a6958 100644 --- a/theHarvester/discovery/githubcode.py +++ b/theHarvester/discovery/githubcode.py @@ -89,6 +89,13 @@ async def handle_response(self, response: tuple[str, dict, int, Any]) -> ErrorRe print(f'Error handling response: {e}') return ErrorResult(500, str(e)) + @staticmethod + async def next_page_or_end(result: SuccessResult) -> int | None: + if result.next_page is not None: + return result.next_page + else: + return result.last_page + async def do_search(self, page: int) -> tuple[str, dict, int, Any]: try: url = f'{self.base_url}&page={page}' if page else self.base_url