conftest.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # Copyright 2023 Avaiga Private Limited
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  4. # the License. You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  9. # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  10. # specific language governing permissions and limitations under the License.
  11. import os
  12. from pathlib import Path
  13. import pandas as pd # type: ignore
  14. import pytest
  15. from flask import Flask, g
  16. csv = pd.read_csv(
  17. f"{Path(Path(__file__).parent.resolve())}{os.path.sep}current-covid-patients-hospital.csv", parse_dates=["Day"]
  18. )
  19. small_dataframe_data = {"name": ["A", "B", "C"], "value": [1, 2, 3]}
  20. @pytest.fixture(scope="function")
  21. def csvdata():
  22. yield csv
  23. @pytest.fixture(scope="function")
  24. def small_dataframe():
  25. yield small_dataframe_data
  26. @pytest.fixture(scope="function")
  27. def gui(helpers):
  28. from taipy.gui import Gui
  29. gui = Gui()
  30. yield gui
  31. # Delete Gui instance and state of some classes after each test
  32. gui.stop()
  33. helpers.test_cleanup()
  34. @pytest.fixture
  35. def helpers():
  36. from .helpers import Helpers
  37. return Helpers
  38. @pytest.fixture
  39. def test_client():
  40. flask_app = Flask("Test App")
  41. # Create a test client using the Flask application configured for testing
  42. with flask_app.test_client() as testing_client:
  43. # Establish an application context
  44. with flask_app.app_context():
  45. g.client_id = "test client id"
  46. yield testing_client # this is where the testing happens!