(venv, bake_examples_compiled_dev_version)
| 34 | |
| 35 | |
| 36 | def test_dev_version_number(venv, bake_examples_compiled_dev_version): |
| 37 | cj = bake_examples_compiled_dev_version |
| 38 | path = str(cj.project_path) |
| 39 | |
| 40 | subprocess.run(["git", "init", path], check=True) |
| 41 | with open(cj.project_path / ".gitignore", "w") as fobj: |
| 42 | fobj.writelines([ |
| 43 | "packagename/_compiler.c\n", |
| 44 | "packagename/_version.py\n", |
| 45 | "packagename/example_c.c\n", |
| 46 | "*.so\n", |
| 47 | "*.egg-info\n", |
| 48 | "__pycache__\n", |
| 49 | ]) |
| 50 | subprocess.run(["git", "-C", path, "config", "user.name", "Test User"], check=True) |
| 51 | subprocess.run(["git", "-C", path, "config", "user.email", "test@openastronomy.org"], check=True) |
| 52 | subprocess.run(["git", "-C", path, "config", "-l"], check=True) |
| 53 | subprocess.run(["git", "-C", path, "add", "."], check=True) |
| 54 | subprocess.run(["git", "-C", path, "commit", "-m", "initial"], check=True) |
| 55 | subprocess.run(["git", "-C", path, "tag", "v0.1"], check=True) |
| 56 | |
| 57 | # Create a new virtualenv with the package installed |
| 58 | venv.install('setuptools_scm') |
| 59 | venv.install(path, editable=True) |
| 60 | |
| 61 | # assert it's actually correct |
| 62 | dynamic_version = subprocess.run([venv.python, '-c', 'import packagename; print(packagename.__version__)'], |
| 63 | capture_output=True) |
| 64 | assert dynamic_version.stdout.decode().strip() == "0.1" |
| 65 | |
| 66 | with open(cj.project_path / "README.md", "a") as fobj: |
| 67 | fobj.seek(0, io.SEEK_END) |
| 68 | fobj.write("add untracked file to repo") |
| 69 | |
| 70 | subprocess.run(["git", "-C", path, "add", "."], check=True) |
| 71 | subprocess.run(["git", "-C", path, "commit", "-m", "second"], check=True) |
| 72 | |
| 73 | # assert it's actually correct |
| 74 | dynamic_version = subprocess.run([venv.python, '-c', 'import packagename; print(packagename.__version__)'], |
| 75 | capture_output=True) |
| 76 | assert dynamic_version.stdout.decode().startswith("0.2.dev1") |
nothing calls this directly
no outgoing calls
no test coverage detected