From f16585ca7a8160f2a28fd0ffdda0edb511424409 Mon Sep 17 00:00:00 2001 From: Aryan Karamtoth <88923986+SpaciousCoder78@users.noreply.github.com> Date: Tue, 1 Jul 2025 19:01:37 +0530 Subject: [PATCH 1/2] feat: added unit tests with pytest to simplify development This library lacks unit tests which PyPi recommends having so I added them in this commit. Unit tests can now be performed by running `pytest` in the tests directory. --- requirements.txt | 1 + tests/test_googlesearch.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 tests/test_googlesearch.py diff --git a/requirements.txt b/requirements.txt index 56399db..e5e63ad 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ beautifulsoup4>=4.9 requests>=2.20 +pytest \ No newline at end of file diff --git a/tests/test_googlesearch.py b/tests/test_googlesearch.py new file mode 100644 index 0000000..48fceea --- /dev/null +++ b/tests/test_googlesearch.py @@ -0,0 +1,21 @@ +# Introduced unit tests with pytest to make the development process a bit easier +import webbrowser +from googlesearch import * +import pytest + +#sample test query +ser = "test query" + +@pytest.fixture +def search_query(): + return "test query" + +# opening the web browser to test the library since using simple `search("google")` does not work +def test_searchactual(search_query): + search(search_query) + webbrowser.open_new_tab(next(search(search_query))) + return True + +#using pytest to check if the test passes +def test_search(): + assert search(ser) is not None \ No newline at end of file From 76d9e76536700e7e9b4a5e2c80d0066d5dbaab01 Mon Sep 17 00:00:00 2001 From: Aryan Karamtoth <88923986+SpaciousCoder78@users.noreply.github.com> Date: Sat, 27 Sep 2025 21:28:47 +0530 Subject: [PATCH 2/2] Update requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e5e63ad..2db2323 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ beautifulsoup4>=4.9 requests>=2.20 -pytest \ No newline at end of file +pytest>=8.4.1