Exemplo n.º 1
0
def test_update_yaml_list_nesting_does_not_confuse():
    source_lines = textwrap.dedent("""\
        language: python
        matrix:
          include:

            - name: flake8
              script:
                - flake8

            - python: 2.7
              env:
                - PURE_PYTHON: 1
          allow_failures:
            - python: 3.8
        install: pip install -e .
        script: pytest tests
    """).splitlines(True)
    result = update_yaml_list(source_lines, ("matrix", "include"), [],
                              keep=lambda job: job.startswith('python:'))
    assert "".join(result) == textwrap.dedent("""\
        language: python
        matrix:
          include:
            - python: 2.7
              env:
                - PURE_PYTHON: 1
          allow_failures:
            - python: 3.8
        install: pip install -e .
        script: pytest tests
    """)
Exemplo n.º 2
0
def test_update_yaml_list_not_found(capsys):
    source_lines = textwrap.dedent("""\
        language: python
        install: pip install -e .
        script: pytest tests
    """).splitlines(True)
    result = update_yaml_list(source_lines, "python", ["2.7", "3.7"])
    assert "".join(result) == textwrap.dedent("""\
        language: python
        install: pip install -e .
        script: pytest tests
    """)
    assert ("Did not find python: setting in .travis.yml"
            in capsys.readouterr().err)
Exemplo n.º 3
0
def test_update_yaml_list():
    source_lines = textwrap.dedent("""\
        language: python
        python:
          - 2.6
          - 2.7
        install: pip install -e .
        script: pytest tests
    """).splitlines(True)
    result = update_yaml_list(source_lines, "python", ["2.7", "3.7"])
    assert "".join(result) == textwrap.dedent("""\
        language: python
        python:
          - 2.7
          - 3.7
        install: pip install -e .
        script: pytest tests
    """)
Exemplo n.º 4
0
def test_update_yaml_list_nesting_some_garbage():
    source_lines = textwrap.dedent("""\
        language: python
        matrix:
          include:
            - python: 2.7
            garbage
        install: pip install -e .
        script: pytest tests
    """).splitlines(True)
    result = update_yaml_list(source_lines, ("matrix", "include"),
                              ['python: 2.7'])
    assert "".join(result) == textwrap.dedent("""\
        language: python
        matrix:
          include:
            - python: 2.7
            garbage
        install: pip install -e .
        script: pytest tests
    """)
Exemplo n.º 5
0
def test_update_yaml_list_nested_keys_not_found(capsys):
    source_lines = textwrap.dedent("""\
        language: python
        matrix:
          allow_failures:
            - python: 3.8
        install: pip install -e .
        script: pytest tests
    """).splitlines(True)
    result = update_yaml_list(source_lines, ("matrix", "include"),
                              ["python: 2.7"])
    assert "".join(result) == textwrap.dedent("""\
        language: python
        matrix:
          allow_failures:
            - python: 3.8
        install: pip install -e .
        script: pytest tests
    """)
    assert ("Did not find matrix.include: setting in .travis.yml"
            in capsys.readouterr().err)
Exemplo n.º 6
0
def test_update_yaml_list_keep_indent_comments_and_pypy():
    source_lines = textwrap.dedent("""\
        language: python
        python:
           - 2.6
          # XXX: should probably remove 2.6
           - 2.7
           - pypy
           - 3.3
        script: pytest tests
    """).splitlines(True)
    result = update_yaml_list(source_lines,
                              "python", ["2.7", "3.7"],
                              keep=lambda line: line == 'pypy')
    assert "".join(result) == textwrap.dedent("""\
        language: python
        python:
           - 2.7
           - 3.7
          # XXX: should probably remove 2.6
           - pypy
        script: pytest tests
    """)