~autopilot/window-mocker/1.0

« back to all changes in this revision

Viewing changes to windowmocker/__init__.py

  • Committer: Michael Terry
  • Date: 2013-02-07 16:41:10 UTC
  • Revision ID: michael.terry@canonical.com-20130207164110-bginp034j65w5f2n
rename testapp to window-maker

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
from threading import Thread
16
16
 
17
17
 
18
 
from testapp import plugins
 
18
from windowmocker import plugins
19
19
 
20
20
__all__ = (
21
21
    'create_application_from_data',
22
22
    'create_application_from_file',
23
23
    'create_application_from_path',
24
 
    'launch_testapp_with_data',
 
24
    'launch_window_mocker_with_data',
25
25
    )
26
26
 
27
27
 
92
92
    app_instance.run()
93
93
 
94
94
 
95
 
def launch_testapp_with_data(data=None):
96
 
    """Run testapp with the contents of 'data' as the window spec file.
 
95
def launch_window_mocker_with_data(data=None):
 
96
    """Run window-mocker with the contents of 'data' as the window spec file.
97
97
 
98
98
    If data is None (the default), a default window will be created. This
99
99
    function returns a threading.Thread object that has been started. While the
100
100
    window is active, the thread will remain running.
101
101
 
102
 
    This function writes 'data' to a temporary file on disk, and calls testapp
103
 
    on that spec file. The file is cleaned up afterwards.
 
102
    This function writes 'data' to a temporary file on disk, and calls
 
103
    window-mocker on that spec file. The file is cleaned up afterwards.
104
104
 
105
 
    testapp must be in $PATH.
 
105
    window-mocker must be in $PATH.
106
106
 
107
107
    """
108
108
    if data is None:
118
118
        with open(file_path, 'w') as f:
119
119
            json.dump(data, f)
120
120
        try:
121
 
            subprocess.check_call(["testapp", file_path])
 
121
            subprocess.check_call(["window-mocker", file_path])
122
122
        finally:
123
123
            os.remove(file_path)
124
124