def test_update_travis_yml_python_versions_keeps_matrix(): travis_yml = StringIO(textwrap.dedent("""\ language: python python: - 2.7 matrix: include: - python: 2.7 env: MINIMAL=1 install: pip install -e . script: pytest tests """)) travis_yml.name = '.travis.yml' result = update_travis_yml_python_versions(travis_yml, v(["2.7", "3.7"])) assert "".join(result) == textwrap.dedent("""\ language: python python: - 2.7 - 3.7 matrix: include: - python: 2.7 env: MINIMAL=1 install: pip install -e . script: pytest tests """)
def test_update_travis_yml_python_versions_matrix_xenial(monkeypatch): monkeypatch.setitem( XENIAL_SUPPORTED_PYPY_VERSIONS, 'pypy', 'pypy2.7-6.0.0') travis_yml = StringIO(textwrap.dedent("""\ language: python matrix: exclude: - python: 2.6 # this is where the fun begins! include: - python: 2.7 - python: 3.3 - python: pypy - name: docs python: 2.7 install: pip install sphinx script: sphinx-build . - name: flake8 python: 2.7 install: pip install flake8 script: flake8 . install: pip install -e . script: pytest tests """)) travis_yml.name = '.travis.yml' result = update_travis_yml_python_versions(travis_yml, v(["2.7", "3.7"])) assert "".join(result) == textwrap.dedent("""\ language: python matrix: exclude: - python: 2.6 # this is where the fun begins! include: - python: 2.7 - python: 3.7 - python: pypy2.7-6.0.0 - name: docs python: 2.7 install: pip install sphinx script: sphinx-build . - name: flake8 python: 2.7 install: pip install flake8 script: flake8 . install: pip install -e . script: pytest tests """)
def test_update_travis_yml_python_versions_one_to_many(): travis_yml = StringIO(textwrap.dedent("""\ language: python python: 2.7 install: pip install -e . script: pytest tests """)) travis_yml.name = '.travis.yml' result = update_travis_yml_python_versions(travis_yml, v(["2.7", "3.4"])) assert "".join(result) == textwrap.dedent("""\ language: python python: - 2.7 - 3.4 install: pip install -e . script: pytest tests """)
def test_update_travis_yml_python_versions_matrix(): travis_yml = StringIO(textwrap.dedent("""\ language: python matrix: exclude: - python: 2.6 # this is where the fun begins! include: - python: 2.7 - python: 3.3 - python: pypy - name: docs python: 2.7 install: pip install sphinx script: sphinx-build . - name: flake8 python: 2.7 install: pip install flake8 script: flake8 . install: pip install -e . script: pytest tests """)) travis_yml.name = '.travis.yml' result = update_travis_yml_python_versions(travis_yml, v(["2.7", "3.4"])) assert "".join(result) == textwrap.dedent("""\ language: python matrix: exclude: - python: 2.6 # this is where the fun begins! include: - python: 2.7 - python: 3.4 - python: pypy - name: docs python: 2.7 install: pip install sphinx script: sphinx-build . - name: flake8 python: 2.7 install: pip install flake8 script: flake8 . install: pip install -e . script: pytest tests """)
def test_update_travis_yml_python_versions_as_strings(): travis_yml = StringIO(textwrap.dedent("""\ language: python python: - "3.4" - pypy3 install: pip install -e . script: pytest tests """)) travis_yml.name = '.travis.yml' result = update_travis_yml_python_versions(travis_yml, v(["3.9"])) assert "".join(result) == textwrap.dedent("""\ language: python python: - "3.9" - pypy3 install: pip install -e . script: pytest tests """)
def test_update_travis_yml_python_versions_keeps_dev(): travis_yml = StringIO(textwrap.dedent("""\ language: python python: - 3.7 - 3.8 - 3.9-dev install: pip install -e . script: pytest tests """)) travis_yml.name = '.travis.yml' result = update_travis_yml_python_versions(travis_yml, v(["3.8"])) assert "".join(result) == textwrap.dedent("""\ language: python python: - 3.8 - 3.9-dev install: pip install -e . script: pytest tests """)
def test_update_travis_yml_python_versions_drops_sudo(): travis_yml = StringIO(textwrap.dedent("""\ language: python sudo: false dist: xenial python: - 2.7 install: pip install -e . script: pytest tests """)) travis_yml.name = '.travis.yml' result = update_travis_yml_python_versions(travis_yml, v(["2.7", "3.7"])) assert "".join(result) == textwrap.dedent("""\ language: python dist: xenial python: - 2.7 - 3.7 install: pip install -e . script: pytest tests """)
def test_update_travis_yml_python_versions_3_10(): travis_yml = StringIO(textwrap.dedent("""\ language: python python: - 3.4 - pypy3 install: pip install -e . script: pytest tests """)) travis_yml.name = '.travis.yml' result = update_travis_yml_python_versions(travis_yml, v(["3.9", "3.10"])) # Note: we cannot say '- 3.10', that's a float and evaluates to 3.1! assert "".join(result) == textwrap.dedent("""\ language: python python: - 3.9 - "3.10" - pypy3 install: pip install -e . script: pytest tests """)
def test_update_travis_yml_python_versions_drops_pypy3(): # yes this test case is massively unrealistic travis_yml = StringIO(textwrap.dedent("""\ language: python python: - 2.7 - 3.4 - pypy - pypy3 install: pip install -e . script: pytest tests """)) travis_yml.name = '.travis.yml' result = update_travis_yml_python_versions(travis_yml, v(["2.7"])) assert "".join(result) == textwrap.dedent("""\ language: python python: - 2.7 - pypy install: pip install -e . script: pytest tests """)
def test_update_travis_yml_python_versions_matrix_preserve_quotes(): travis_yml = StringIO(textwrap.dedent("""\ language: python matrix: include: - python: "2.7" - python: "3.3" - language: c install: pip install tox script: tox -e py """)) travis_yml.name = '.travis.yml' result = update_travis_yml_python_versions(travis_yml, v(["3.8", "3.9"])) assert "".join(result) == textwrap.dedent("""\ language: python matrix: include: - python: "3.8" - python: "3.9" - language: c install: pip install tox script: tox -e py """)
def test_update_travis_yml_python_versions_drops_dist_trusty(monkeypatch): monkeypatch.setitem( XENIAL_SUPPORTED_PYPY_VERSIONS, 'pypy', 'pypy2.7-6.0.0') travis_yml = StringIO(textwrap.dedent("""\ language: python dist: trusty python: - 2.7 - pypy install: pip install -e . script: pytest tests """)) travis_yml.name = '.travis.yml' result = update_travis_yml_python_versions(travis_yml, v(["2.7", "3.7"])) assert "".join(result) == textwrap.dedent("""\ language: python python: - 2.7 - 3.7 - pypy2.7-6.0.0 install: pip install -e . script: pytest tests """)
def test_update_travis_yml_python_versions_drops_matrix(): travis_yml = StringIO(textwrap.dedent("""\ language: python python: - 2.6 - 2.7 matrix: include: - python: 3.7 sudo: required dist: xenial install: pip install -e . script: pytest tests """)) travis_yml.name = '.travis.yml' result = update_travis_yml_python_versions(travis_yml, v(["2.7", "3.7"])) assert "".join(result) == textwrap.dedent("""\ language: python python: - 2.7 - 3.7 install: pip install -e . script: pytest tests """)