Esempio n. 1
0
 def test__launch_flexlogger_and_disconnect__connect_to_existing_and_open_project__is_not_None(
     self, ) -> None:
     kill_all_open_flexloggers()
     project_path = get_project_path("DefaultProject")
     server_port = -1
     try:
         with Application.launch() as app:
             server_port = app.server_port
             # This should prevent FlexLogger from closing when app goes out of scope
             app.disconnect()
         with Application(server_port=server_port) as app:
             project = app.open_project(project_path)
             assert project is not None
     finally:
         if server_port != -1:
             Application(server_port=server_port).close()
Esempio n. 2
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()
Esempio n. 3
0
    def test__connect_to_application__close_application__application_has_closed(
            self) -> None:
        kill_all_open_flexloggers()
        app = Application.launch()
        # Opening a project will make closing the application take longer
        app.open_project(get_project_path("DefaultProject"))

        app2 = Application(app.server_port)
        app2.close()

        assert_no_flexloggers_running()
Esempio n. 4
0
    def test__launch_flexlogger_separately__connect_to_existing_and_close__application_has_closed(
        self, ) -> None:
        kill_all_open_flexloggers()
        # Launch the way that Application.launch() does, but don't connect
        real_server_port = Application._launch_flexlogger(60)
        # The port file doesn't get written out until slightly after the mapped file
        # that _launch_flexlogger() is waiting for.
        # So wait for the file to exist before proceeding with the test.
        server_port_file_path = Application._get_server_port_file_path()
        while not server_port_file_path.exists():
            sleep(1)

        app = Application()
        assert real_server_port == app.server_port
        app.close()

        assert_no_flexloggers_running()
def main():
    """Connect to an already running instance of FlexLogger with an open project

    Note that before connecting to an already running instance of FlexLogger,
    the Automation server preference must be enabled. You can enable this preference by opening the
    "File>>Preferences" menu item, and then enabling the "Automation server" preference in the
    "General" tab.
    """
    app = Application()
    project = app.get_active_project()
    if project is None:
        print("No project is open in FlexLogger!")
        return 1
    test_session_state = project.test_session.state
    print("The test session state is:")
    print(test_session_state)
    print("Press Enter to disconnect from FlexLogger...")
    input()
    app.disconnect()
    return 0