Skip to content

Commit

Permalink
Update integration tests for latest sampleproject (#947)
Browse files Browse the repository at this point in the history
* Turn off flaky mark that hides root cause

* Rework sampleproject fixture to use pyproject.toml

* Make better use of pathlib
  • Loading branch information
bhrutledge committed Dec 5, 2022
1 parent a43f6ea commit 591e46b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
41 changes: 26 additions & 15 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,41 @@
from twine import __main__ as dunder_main
from twine import cli

pytestmark = [
pytest.mark.enable_socket,
pytest.mark.flaky(reruns=3, reruns_delay=1),
]
pytestmark = [pytest.mark.enable_socket]


@pytest.fixture(scope="session")
def sampleproject_dist(tmp_path_factory):
def sampleproject_dist(tmp_path_factory: pytest.TempPathFactory):
checkout = tmp_path_factory.mktemp("sampleproject", numbered=False)
tag = datetime.datetime.now().strftime("%Y%m%d%H%M%S%f")

subprocess.run(
["git", "clone", "https://github.com/pypa/sampleproject", str(checkout)]
["git", "clone", "https://github.com/pypa/sampleproject", str(checkout)],
check=True,
)
with (checkout / "setup.py").open("r+") as setup:
orig = setup.read()
sub = orig.replace('name="sampleproject"', 'name="twine-sampleproject"')
assert orig != sub
setup.seek(0)
setup.write(sub)
tag = datetime.datetime.now().strftime("%Y%m%d%H%M%S%f")

pyproject = checkout / "pyproject.toml"
pyproject.write_text(
pyproject.read_text()
.replace(
'name = "sampleproject"',
'name = "twine-sampleproject"',
)
.replace(
'version = "3.0.0"',
f'version = "3.0.0post{tag}"',
)
)

subprocess.run(
[sys.executable, "setup.py", "egg_info", "--tag-build", f"post{tag}", "sdist"],
[sys.executable, "-m", "build", "--sdist"],
check=True,
cwd=str(checkout),
)
(dist,) = checkout.joinpath("dist").glob("*")

[dist, *_] = (checkout / "dist").glob("*")
assert dist.name == f"twine-sampleproject-3.0.0.post{tag}.tar.gz"

return dist


Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ deps =
portend
pytest-rerunfailures
pytest-services
build
passenv =
PYTEST_ADDOPTS
commands =
Expand Down

0 comments on commit 591e46b

Please sign in to comment.