'Build a Python script to run the tests.'

def generate_testing_command(self):

    cmd_pre = ''
    cmd_post = ''
    if self.coverage:
        (pre, post) = self._generate_coverage_commands()
        cmd_pre += pre
        cmd_post += post
    if six.PY2:
        set_flag = 'import    __builtin__;    __builtin__._ASTROPY_TEST_    =    True'
    else:
        set_flag = 'import    builtins;    builtins._ASTROPY_TEST_    =    True'
    cmd = '{cmd_pre}{0};    import    {1.package_name},    sys;    result    =    ({1.package_name}.test(package={1.package!r},    test_path={1.test_path!r},    args={1.args!r},    plugins={1.plugins!r},    verbose={1.verbose_results!r},    pastebin={1.pastebin!r},    remote_data={1.remote_data!r},    pep8={1.pep8!r},    pdb={1.pdb!r},    open_files={1.open_files!r},    parallel={1.parallel!r},    docs_path={1.docs_path!r},    skip_docs={1.skip_docs!r},    repeat={1.repeat!r}));    {cmd_post}sys.exit(result)'
    return cmd.format(set_flag, self, cmd_pre=cmd_pre, cmd_post=cmd_post)
