diff --git a/setup.py b/setup.py index a113c237..967b2ac1 100644 --- a/setup.py +++ b/setup.py @@ -3,10 +3,9 @@ # Read requirements.txt, ignore comments try: with open("requirements.txt", "r") as f: - REQUIRES = [line.split('#', 1)[0].strip() for line in f if line.strip()] -except: - print("'requirements.txt' not found!") - REQUIRES = list() + REQUIRES = [line.split("#", 1)[0].strip() for line in f if line.strip()] +except FileNotFoundError: + raise FileNotFoundError("requirements.txt not found!") setup( name="FinGPT", diff --git a/tests/test_setup.py b/tests/test_setup.py new file mode 100644 index 00000000..f66110ca --- /dev/null +++ b/tests/test_setup.py @@ -0,0 +1,20 @@ +import os +import pytest + +def test_requirements_exists(): + assert os.path.exists("requirements.txt") + +def test_requirements_not_empty(): + with open("requirements.txt", "r") as f: + lines = [line.strip() for line in f if line.strip()] + assert len(lines) > 0 + +def test_requirements_commented_lines(): + with open("requirements.txt", "r") as f: + for line in f: + assert "#" in line or line.strip() != "" + +def test_setup_runs(): + import subprocess + result = subprocess.run(["python", "setup.py", "--name"], capture_output=True, text=True) + assert "FinGPT" in result.stdout