diff --git a/.coverage.Colins-Air.indiana.edu.21211.834887 b/.coverage.Colins-Air.indiana.edu.21211.834887 deleted file mode 100644 index d4e86972b75..00000000000 Binary files a/.coverage.Colins-Air.indiana.edu.21211.834887 and /dev/null differ diff --git a/gamestonk_terminal/parent_classes.py b/gamestonk_terminal/parent_classes.py index 75927637b11..d14554df9d0 100644 --- a/gamestonk_terminal/parent_classes.py +++ b/gamestonk_terminal/parent_classes.py @@ -422,11 +422,6 @@ class StockBaseController(BaseController, metaclass=ABCMeta): "--file", default=None, help="Path to load custom file.", - choices=[ - x - for x in os.listdir(os.path.join("custom_imports", "stocks")) - if x.endswith(".csv") - ], dest="filepath", type=str, ) @@ -478,6 +473,21 @@ class StockBaseController(BaseController, metaclass=ABCMeta): monthly=ns_parser.monthly, ) else: + # This seems to block the .exe since the folder needs to be manually created + # This block basically makes sure that we only look for the file if the -f flag is used + # If we add files in the argparse choices, it will fail for the .exe even if no -f is used + try: + if ns_parser.filepath not in os.listdir( + os.path.join("custom_imports", "stocks") + ): + console.print( + f"[red]{ns_parser.filepath} not found in custom_imports/stocks/ folder[/red].\n" + ) + return + except Exception as e: + console.print(e) + return + df_stock_candidate = stocks_helper.load_custom( os.path.join( os.path.join("custom_imports", "stocks"), ns_parser.filepath diff --git a/tests/gamestonk_terminal/stocks/test_stocks_helper.py b/tests/gamestonk_terminal/stocks/test_stocks_helper.py index b7cf4226bc6..1253ea4321f 100644 --- a/tests/gamestonk_terminal/stocks/test_stocks_helper.py +++ b/tests/gamestonk_terminal/stocks/test_stocks_helper.py @@ -102,6 +102,16 @@ def test_load_custom_output(path): stocks_helper.load_custom(path) +@pytest.mark.vcr +@pytest.mark.record_stdout +@pytest.mark.parametrize( + "path", + [os.path.join(os.path.join("random_folder", "test69.csv"))], +) +def test_load_custom_output_wrong_path(path): + stocks_helper.load_custom(path) + + @pytest.mark.vcr @pytest.mark.parametrize( "path", diff --git a/tests/gamestonk_terminal/stocks/txt/test_stocks_helper/test_load_custom[custom_imports/stocks/test.csv].txt b/tests/gamestonk_terminal/stocks/txt/test_stocks_helper/test_load_custom[custom_imports/stocks/test.csv].txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/gamestonk_terminal/stocks/txt/test_stocks_helper/test_load_custom[none].txt b/tests/gamestonk_terminal/stocks/txt/test_stocks_helper/test_load_custom[none].txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/gamestonk_terminal/stocks/txt/test_stocks_helper/test_load_custom_output_wrong_path[random_folder/test69.csv].txt b/tests/gamestonk_terminal/stocks/txt/test_stocks_helper/test_load_custom_output_wrong_path[random_folder/test69.csv].txt new file mode 100644 index 00000000000..bd36dc5f6d0 --- /dev/null +++ b/tests/gamestonk_terminal/stocks/txt/test_stocks_helper/test_load_custom_output_wrong_path[random_folder/test69.csv].txt @@ -0,0 +1,2 @@ +[red]File path does not exist.[/red] +