def test_dump_version(tmpdir): sp = tmpdir.strpath dump_version(sp, '1.0', 'first.txt') assert tmpdir.join('first.txt').read() == '1.0' dump_version(sp, '1.0', 'first.py') content = tmpdir.join('first.py').read() assert repr('1.0') in content import ast ast.parse(content)
def test_dump_version(tmpdir): sp = tmpdir.strpath dump_version(sp, "1.0", "first.txt") assert tmpdir.join("first.txt").read() == "1.0" dump_version(sp, "1.0", "first.py") content = tmpdir.join("first.py").read() assert repr("1.0") in content import ast ast.parse(content)
def test_dump_version(tmpdir): sp = tmpdir.strpath dump_version(sp, "1.0", "first.txt") assert tmpdir.join("first.txt").read() == "1.0" dump_version(sp, "1.0.dev42", "first.py") content = tmpdir.join("first.py").read() lines = content.splitlines() assert "version = '1.0.dev42'" in lines assert "version_tuple = (1, 0, 'dev42')" in lines dump_version(sp, "1.0.1+g4ac9d2c", "second.py") content = tmpdir.join("second.py").read() lines = content.splitlines() assert "version = '1.0.1+g4ac9d2c'" in lines assert "version_tuple = (1, 0, 1, 'g4ac9d2c')" in lines dump_version(sp, "1.2.3.dev18+gb366d8b.d20210415", "third.py") content = tmpdir.join("third.py").read() lines = content.splitlines() assert "version = '1.2.3.dev18+gb366d8b.d20210415'" in lines assert "version_tuple = (1, 2, 3, 'dev18', 'gb366d8b.d20210415')" in lines import ast ast.parse(content)
def test_dump_version(tmpdir): sp = tmpdir.strpath dump_version(sp, "1.0", "first.txt") assert tmpdir.join("first.txt").read() == "1.0" dump_version(sp, "1.0.dev42", "first.py") content = tmpdir.join("first.py").read() lines = content.splitlines() assert "version = '1.0.dev42'" in lines assert "version_tuple = (1, 0, 'dev42')" in lines import ast ast.parse(content)
def test_dump_version_doesnt_bail_on_value_error(tmpdir): write_to = "VERSION" version = str(VERSIONS["exact"].tag) with pytest.raises(ValueError) as exc_info: dump_version(tmpdir.strpath, version, write_to) assert str(exc_info.value).startswith("bad file format:")