Example #1
0
def test_drop_yaml_node_when_duplicate(capsys):
    source_lines = textwrap.dedent("""\
        language: python
        sudo: false
        matrix:
          include:
            - python: 2.7
        python:
           - 3.6
        matrix:
          include:
            - python: 3.7
        script: pytest tests
    """).splitlines(True)
    result = drop_yaml_node(source_lines, 'matrix')
    assert "".join(result) == textwrap.dedent("""\
        language: python
        sudo: false
        matrix:
          include:
            - python: 2.7
        python:
           - 3.6
        script: pytest tests
    """)
    assert ("Duplicate matrix: setting in .travis.yml (lines 3 and 8)"
            in capsys.readouterr().err)
Example #2
0
def test_drop_yaml_node_when_missing():
    source_lines = textwrap.dedent("""\
        language: python
        python:
           - 3.6
        script: pytest tests
    """).splitlines(True)
    result = drop_yaml_node(source_lines, 'matrix')
    assert "".join(result) == textwrap.dedent("""\
        language: python
        python:
           - 3.6
        script: pytest tests
    """)
Example #3
0
def test_drop_yaml_node_when_text():
    source_lines = textwrap.dedent("""\
        language: python
        sudo: false
        python:
           - 3.6
        script: pytest tests
    """).splitlines(True)
    result = drop_yaml_node(source_lines, 'sudo')
    assert "".join(result) == textwrap.dedent("""\
        language: python
        python:
           - 3.6
        script: pytest tests
    """)
Example #4
0
def test_drop_yaml_node_when_last_in_file():
    source_lines = textwrap.dedent("""\
        language: python
        python:
           - 3.6
        matrix:
          include:
            - python: 3.7
              dist: xenial
              sudo: required
    """).splitlines(True)
    result = drop_yaml_node(source_lines, 'matrix')
    assert "".join(result) == textwrap.dedent("""\
        language: python
        python:
           - 3.6
    """)