diff --git a/requirements.txt b/requirements.txt index 56399db..2db2323 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ beautifulsoup4>=4.9 requests>=2.20 +pytest>=8.4.1 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