OpenBB-finance / OpenBB

Investment Research for Everyone, Everywhere.
https://openbb.co
Other
32.1k stars 2.93k forks source link

[Bug] unwanted dependency of 2 tests #2672

Closed tarpas closed 2 years ago

tarpas commented 2 years ago

Describe the bug It's the test suite bug. One of the tests corrupts the state/environment so that the next one fails. The natural order of tests doesn't expose this because test_quiverquant_view.py goes before test_openinsider_view.py. However, this can change so with plugins like pytest-xdist, or pytest-reverse or pytest-testmon, so I would be great to fix it, if easy.

To Reproduce I think it's easy to reproduce in any environment, just copy the first line from below to your prompt. Let me know please if not, I can show a github actions run where this happens.

pytest "tests/openbb_terminal/stocks/insider/test_openinsider_view.py::test_print_insider_filter" "tests/openbb_terminal/stocks/government/test_quiverquant_view.py::test_call_func[display_government_buys-kwargs_dict1]" -v --tb=native --capture=no
========================================== test session starts ==========================================
platform darwin -- Python 3.9.13, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 -- /Users/tibor/miniforge3/envs/obb/bin/python3.9
cachedir: .pytest_cache
rootdir: /Users/tibor/tmonworkspace/OpenBBTerminal, configfile: pytest.ini
plugins: anyio-3.6.1, xdist-2.5.0, forked-1.4.0, reverse-1.5.0, recording-0.12.1, mock-3.8.2, cov-3.0.0, testmon-dev-1.4.0b0, tmnet-1.3.6, testmon-1.4.0b0
collected 2 items                                                                                       

tests/openbb_terminal/stocks/insider/test_openinsider_view.py::test_print_insider_filter PASSED
tests/openbb_terminal/stocks/government/test_quiverquant_view.py::test_call_func[display_government_buys-kwargs_dict1] PASSED
tests/openbb_terminal/stocks/government/test_quiverquant_view.py::test_call_func[display_government_buys-kwargs_dict1] ERROR

================================================ ERRORS =================================================
_______________ ERROR at teardown of test_call_func[display_government_buys-kwargs_dict1] _______________
Traceback (most recent call last):
  File "/Users/tibor/tmonworkspace/OpenBBTerminal/tests/conftest.py", line 467, in record_stdout
    recorder.assert_equal()
  File "/Users/tibor/tmonworkspace/OpenBBTerminal/tests/conftest.py", line 233, in assert_equal
    raise AssertionError(
AssertionError: Change detected
Record    : /Users/tibor/tmonworkspace/OpenBBTerminal/tests/openbb_terminal/stocks/government/txt/test_quiverquant_view/test_call_func[display_government_buys-kwargs_dict1].txt
Expected  :      ReportDate TransactionDate  ...            House              Range
0    2022-08-08      2022-08-03  ...  Representatives    $15,001-$50,000
1    2022-08-08      2022-08-03  ...  Representatives    $15,001-$50,000
2    2022-08-08      2022-07-27  ...  Representatives     $1,001-$15,000
3    2022-08-07      2022-07-29  ...  Representatives     $1,001-$15,000
4    2022-08-05      2022-08-04  ...  Representatives     $1,001-$15,000
..          ...             ...  ...              ...         
Actual    :      ReportDate TransactionDate  Ticker  ...     Amount            House                    Range
0    2022-08-08  2022-08-03      OZKAP   ...  15001.0    Representatives  $15,001-$50,000        
1    2022-08-08  2022-08-03      DURA    ...  15001.0    Representatives  $15,001-$50,000        
2    2022-08-08  2022-07-27      PHG     ...  1001.0     Representatives  $1,001-$15,000         
3    2022-08-07  2022-07-29      MDT     ...  1001.0     Representatives  $1,001-$15,000         
4    2022-

======================================== short test summary info ========================================
ERROR tests/openbb_terminal/stocks/government/test_quiverquant_view.py::test_call_func[display_government_buys-kwargs_dict1]
====================================== 2 passed, 1 error in 0.68s =======================================

Desktop (please complete the following information):

Additional context Add any other information that you think could be useful for us.

colin99d commented 2 years ago
Screen Shot 2022-09-30 at 6 43 19 AM

pytest "tests/openbb_terminal/stocks/insider/test_openinsider_view.py::test_print_insider_filter" "tests/openbb_terminal/stocks/government/test_quiverquant_view.py::test_call_func[display_government_buys-kwargs_dict1]" -v --tb=native --capture=no passes for me just fine.

tarpas commented 2 years ago

Seems to have been fixed by 446a29ec91bda5111.