コード例 #1
0
 def test__disconnect_application__using_application_raises_exception(
         self) -> None:
     kill_all_open_flexloggers()
     original_app = Application.launch()
     try:
         new_app = Application(server_port=original_app.server_port)
         new_app.disconnect()
         with pytest.raises(FlexLoggerError):
             new_app.open_project(get_project_path("DefaultProject"))
     finally:
         original_app.close()
コード例 #2
0
 def test__close_project_with_channels__get_value__exception_raised(
         self, app: Application) -> None:
     project = app.open_project(get_project_path("ProjectWithProducedData"))
     channel_specification = project.open_channel_specification_document()
     project.close()
     with pytest.raises(FlexLoggerError):
         channel_specification.get_channel_value("Channel 1")
 def test__close_project__get_test_properties__exception_raised(
         self, app: Application) -> None:
     project = app.open_project(get_project_path("ProjectWithProducedData"))
     logging_specification = project.open_logging_specification_document()
     project.close()
     with pytest.raises(FlexLoggerError):
         logging_specification.get_test_properties()
コード例 #4
0
def open_project(application: Application, project_name: str) -> Iterator[Project]:
    """Copy the project with name project_name in the assets directory to a temp directory and open it.

    This function returns a ContextManager, so it should be used in a `with` statement,
    and when it goes out of scope it will close the project and delete the temporary directory.
    """
    with copy_project(project_name) as project_path:
        project = application.open_project(project_path)
        try:
            yield project
        finally:
            project.close()
コード例 #5
0
def project_with_produced_data(app: Application) -> Iterator[Project]:
    """Fixture for opening ProjectWithProducedData.

    This is useful to improve test time by not opening/closing this project in every test.
    """
    with copy_project("ProjectWithProducedData") as project_path:
        project = app.open_project(project_path)
        yield project
        try:
            project.close()
        except FlexLoggerError:
            # utils.kill_all_open_flexloggers may have killed this process already, that's fine
            pass
コード例 #6
0
 def test__remove_channel_specification_file__open_project__raises_exception(
         self, app: Application) -> None:
     with copy_project("DefaultProject") as project_path:
         cache_dir = project_path.parent / ".cache"
         if cache_dir.exists():
             rmtree(str(cache_dir))
         (project_path.parent / "Channel Specification.flxio").unlink()
         project = None
         try:
             with pytest.raises(FlexLoggerError):
                 project = app.open_project(project_path)
         finally:
             if project is not None:
                 project.close()
コード例 #7
0
 def test__close_project__start_test__exception_raised(self, app: Application) -> None:
     project = app.open_project(get_project_path("ProjectWithProducedData"))
     project.close()
     with pytest.raises(FlexLoggerError):
         project.test_session.start()