예제 #1
0
def main():
    version = run([SPHINXBUILD, '--version'], stdout=PIPE, cwd=BASE_DIR,
                  encoding='utf-8').stdout.lstrip('sphinx-build ')
    if StrictVersion(version) < '1.7':
        print('This script requires Sphinx 1.7 or later; got %s.\n' % version)
        sys.exit(2)
    failing = get_doctest_output()
    if not failing:
        print('All doctests are OK')
        sys.exit(0)
    if tools.has_uncommitted_changes(BASE_DIR):
        print('Cannot fix doctests in place with uncommited changes')
        sys.exit(1)

    for fname, examples in failing.items():
        with open(fname) as f:
            lines = f.readlines()
        for ex in examples:
            # Note: can't indent earlier, as we don't know file indentation
            lines[ex.indices] = indent_like(ex.got_lines, lines[ex.indices])
        with open(fname, 'w') as f:
            f.writelines(lines)

    still_failing = get_doctest_output()
    if still_failing:
        print('Fixes failed: script broken or flaky tests.\n', still_failing)
        sys.exit(1)
    print('All failing doctests have been fixed.')
    sys.exit(0)
예제 #2
0
def main():
    version = run([SPHINXBUILD, "--version"],
                  stdout=PIPE,
                  cwd=BASE_DIR,
                  encoding="utf-8").stdout.lstrip("sphinx-build ")
    if StrictVersion(version) < "1.7":
        print("This script requires Sphinx 1.7 or later; got %s.\n" % version)
        sys.exit(2)
    failing = get_doctest_output()
    if not failing:
        print("All doctests are OK")
        sys.exit(0)
    if tools.has_uncommitted_changes(BASE_DIR):
        print("Cannot fix doctests in place with uncommited changes")
        sys.exit(1)

    for fname, examples in failing.items():
        with open(fname) as f:
            lines = f.readlines()
        for ex in examples:
            # Note: can't indent earlier, as we don't know file indentation
            lines[ex.indices] = indent_like(ex.got_lines, lines[ex.indices])
        with open(fname, "w") as f:
            f.writelines(lines)

    still_failing = get_doctest_output()
    if still_failing:
        print("Fixes failed: script broken or flaky tests.\n", still_failing)
        sys.exit(1)
    print("All failing doctests have been fixed.")
    sys.exit(0)
예제 #3
0
def main():
    os.chdir(tools.ROOT)
    version = run([SPHINXBUILD, '--version'], stdout=PIPE,
                  encoding='utf-8').stdout.lstrip('sphinx-build ')
    if StrictVersion(version) < '1.7':
        print('This script requires Sphinx 1.7 or later; got %s.\n' % version)
        sys.exit(2)
    failing = get_doctest_output()
    if not failing:
        print('All doctests are OK')
        sys.exit(0)
    if tools.has_uncommitted_changes('.'):
        print('Cannot fix doctests in place with uncommited changes')
        sys.exit(1)

    for fname, examples in failing.items():
        with open(fname) as f:
            lines = f.readlines()
        for ex in examples:
            # Note: can't indent earlier, as we don't know file indentation
            lines[ex.indices] = indent_like(ex.got_lines, lines[ex.indices])
        with open(fname, 'w') as f:
            f.writelines(lines)

    still_failing = get_doctest_output()
    if still_failing:
        print('Fixes failed: script broken or flaky tests.\n', still_failing)
        sys.exit(1)
    print('All failing doctests have been fixed.')
    sys.exit(0)
예제 #4
0
def check_requirements():
    if is_pyup_branch() and tools.last_committer() != tools.TOOLING_COMMITER_NAME:
        # Recompile to fix broken formatting etc., but ensure there can't be a loop.
        compile_requirements(upgrade=True)
        if tools.has_uncommitted_changes("requirements"):
            push_pyup_requirements_commit()
            raise RuntimeError("Pushed new requirements; check next build.")
    else:
        compile_requirements(upgrade=False)
예제 #5
0
def update_changelog_for_docs():
    if not tools.has_release():
        return
    if tools.has_uncommitted_changes(tools.CHANGELOG_FILE):
        print('Cannot build documentation with uncommitted changes to '
              'changelog and a pending release. Please commit your changes or '
              'delete your release file.')
        sys.exit(1)
    tools.update_changelog_and_version()
예제 #6
0
def check_requirements():
    if is_pyup_branch():
        compile_requirements(upgrade=True)
    else:
        compile_requirements(upgrade=False)

    if tools.has_uncommitted_changes('requirements'):
        push_pyup_requirements_commit()
        raise RuntimeError('Pushed new requirements; check next build.')
예제 #7
0
def check_requirements():
    if is_pyup_branch():
        compile_requirements(upgrade=True)
    else:
        compile_requirements(upgrade=False)

    if tools.has_uncommitted_changes('requirements'):
        push_pyup_requirements_commit()
        raise RuntimeError('Pushed new requirements; check next build.')
예제 #8
0
def check_requirements():
    if is_pyup_branch():
        compile_requirements(upgrade=True)
    else:
        compile_requirements(upgrade=False)

    if tools.has_uncommitted_changes('requirements'):
        push_pyup_requirements_commit()
        sys.exit(1)
    else:
        sys.exit(0)
예제 #9
0
def check_requirements():
    if is_pyup_branch():
        # We recompile to fix broken formatting etc., but also want to support
        # manual fixes to the bot's PRs and ensure there can't be a loop.
        should_recompile = tools.last_committer() == "pyup-bot"
        compile_requirements(upgrade=should_recompile)
    else:
        compile_requirements(upgrade=False)

    if tools.has_uncommitted_changes("requirements"):
        push_pyup_requirements_commit()
        raise RuntimeError("Pushed new requirements; check next build.")
예제 #10
0
def check_requirements():
    if is_pyup_branch():
        # We recompile to fix broken formatting etc., but also want to support
        # manual fixes to the bot's PRs and ensure there can't be a loop.
        should_recompile = tools.last_committer() == "pyup-bot"
        compile_requirements(upgrade=should_recompile)
    else:
        compile_requirements(upgrade=False)

    if tools.has_uncommitted_changes("requirements"):
        push_pyup_requirements_commit()
        raise RuntimeError("Pushed new requirements; check next build.")
예제 #11
0
def test_release_file_exists_and_is_valid(project, monkeypatch):
    assert not tools.has_uncommitted_changes(project.BASE_DIR)

    monkeypatch.setattr(tools, "create_tag", lambda *args, **kwargs: None)
    monkeypatch.setattr(tools, "push_tag", lambda name: None)
    monkeypatch.setattr(rm, "commit_pending_release", lambda p: None)
    monkeypatch.setattr(project, "upload_distribution", lambda: None)
    monkeypatch.setattr(project, "IN_TEST", True, raising=False)

    try:
        main.do_release(project)

        with open(project.CHANGELOG_FILE) as i:
            changelog = i.read()
        assert project.current_version() in changelog
        assert rm.release_date_string() in changelog

    finally:
        tools.git("checkout", project.BASE_DIR)
        os.chdir(tools.ROOT)
def test_release_file_exists_and_is_valid(project, monkeypatch):
    assert not tools.has_uncommitted_changes(project.BASE_DIR)

    monkeypatch.setattr(tools, "create_tag", lambda *args, **kwargs: None)
    monkeypatch.setattr(tools, "push_tag", lambda name: None)
    monkeypatch.setattr(rm, "commit_pending_release", lambda p: None)
    monkeypatch.setattr(project, "upload_distribution", lambda: None)
    monkeypatch.setattr(project, "IN_TEST", True, raising=False)

    try:
        main.do_release(project)

        with open(project.CHANGELOG_FILE) as i:
            changelog = i.read()
        assert project.current_version() in changelog
        assert rm.release_date_string() in changelog

    finally:
        tools.git("checkout", project.BASE_DIR)
        os.chdir(tools.ROOT)
예제 #13
0
def main():
    os.chdir(tools.ROOT)
    failing = get_doctest_output()
    if not failing:
        print('All doctests are OK')
        sys.exit(0)
    if tools.has_uncommitted_changes('.'):
        print('Cannot fix doctests in place with uncommited changes')
        sys.exit(1)

    for fname, examples in failing.items():
        with open(fname) as f:
            lines = f.readlines()
        for ex in examples:
            lines[ex.indices] = ex.got_lines
        with open(fname, 'w') as f:
            f.writelines(lines)

    still_failing = get_doctest_output()
    if still_failing:
        print('Fixes failed: script broken or flaky tests.\n', still_failing)
        sys.exit(1)
    print('All failing doctests have been fixed.')
    sys.exit(0)
# Most of this work is copyright (C) 2013-2017 David R. MacIver
# ([email protected]), but it contains contributions by others. See
# CONTRIBUTING.rst for a full list of people who may hold copyright, and
# consult the git log if you need to determine who owns an individual
# contribution.
#
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at http://mozilla.org/MPL/2.0/.
#
# END HEADER

from __future__ import division, print_function, absolute_import

import os
import sys

import hypothesistooling as tools

sys.path.append(os.path.dirname(__file__))  # noqa

if __name__ == '__main__':
    if not tools.has_release():
        sys.exit(0)
    if tools.has_uncommitted_changes(tools.CHANGELOG_FILE):
        print('Cannot build documentation with uncommitted changes to '
              'changelog and a pending release. Please commit your changes or '
              'delete your release file.')
        sys.exit(1)
    tools.update_changelog_and_version()
# CONTRIBUTING.rst for a full list of people who may hold copyright, and
# consult the git log if you need to determine who owns an individual
# contribution.
#
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at http://mozilla.org/MPL/2.0/.
#
# END HEADER

from __future__ import division, print_function, absolute_import

import os
import sys

import hypothesistooling as tools

sys.path.append(os.path.dirname(__file__))  # noqa


if __name__ == '__main__':
    if not tools.has_release():
        sys.exit(0)
    if tools.has_uncommitted_changes(tools.CHANGELOG_FILE):
        print(
            'Cannot build documentation with uncommitted changes to '
            'changelog and a pending release. Please commit your changes or '
            'delete your release file.')
        sys.exit(1)
    tools.update_changelog_and_version()