Skip to content

Commit

Permalink
remove unwanted generated files from fixtures (#9103)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby authored Mar 3, 2024
1 parent 173391b commit b8fd4a1
Show file tree
Hide file tree
Showing 26 changed files with 217 additions and 269 deletions.
22 changes: 0 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
*.pyc

# Packages
*.egg
!/tests/**/*.egg
/*.egg-info
/dist/*
build
_build
.cache
*.so

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
Expand All @@ -22,20 +12,8 @@ pip-log.txt
.python-version
.vscode/*

/test.py
/test_*.*

/setup.cfg
MANIFEST.in
/setup.py
/docs/site/*
/tests/fixtures/simple_project/setup.py
/tests/fixtures/project_with_extras/setup.py
.mypy_cache

.venv
/releases/*
pip-wheel-metadata
/poetry.toml

poetry/core/*
10 changes: 0 additions & 10 deletions tests/fixtures/git/github.com/demo/demo/demo.egg-info/PKG-INFO

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Empty file.

This file was deleted.

This file was deleted.

21 changes: 6 additions & 15 deletions tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import os
import re
import shutil
import sys
import urllib.parse

from pathlib import Path
Expand Down Expand Up @@ -74,24 +73,16 @@ def get_dependency(
return Factory.create_dependency(name, constraint or "*", groups=groups)


def copy_or_symlink(source: Path, dest: Path) -> None:
def copy_path(source: Path, dest: Path) -> None:
if dest.is_symlink() or dest.is_file():
dest.unlink() # missing_ok is only available in Python >= 3.8
elif dest.is_dir():
shutil.rmtree(dest)

# os.symlink requires either administrative privileges or developer mode on Win10,
# throwing an OSError if neither is active.
if sys.platform == "win32":
try:
os.symlink(str(source), str(dest), target_is_directory=source.is_dir())
except OSError:
if source.is_dir():
shutil.copytree(str(source), str(dest))
else:
shutil.copyfile(str(source), str(dest))
if source.is_dir():
shutil.copytree(source, dest)
else:
os.symlink(str(source), str(dest))
shutil.copyfile(source, dest)


class MockDulwichRepo:
Expand Down Expand Up @@ -122,7 +113,7 @@ def mock_clone(
dest = source_root / path
dest.parent.mkdir(parents=True, exist_ok=True)

copy_or_symlink(folder, dest)
copy_path(folder, dest)
return MockDulwichRepo(dest)


Expand All @@ -138,7 +129,7 @@ def mock_download(

fixture = FIXTURE_PATH / parts.path.lstrip("/")

copy_or_symlink(fixture, dest)
copy_path(fixture, dest)


class TestExecutor(Executor):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ files = []

[package.source]
type = "directory"
url = "tests/fixtures/project_with_setup"
url = "project"

[package.dependencies]
cachy = {version = ">=0.2.0", extras = ["msgpack"]}
Expand Down
5 changes: 4 additions & 1 deletion tests/installation/test_chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,13 @@ def test_prepare_directory_with_extensions(
config_cache_dir: Path,
artifact_cache: ArtifactCache,
fixture_dir: FixtureDirGetter,
tmp_path: Path,
) -> None:
env = EnvManager.get_system_env()
chef = Chef(artifact_cache, env, Factory.create_pool(config))
archive = fixture_dir("extended_with_no_setup").resolve()
archive = shutil.copytree(
fixture_dir("extended_with_no_setup").resolve(), tmp_path / "project"
)

wheel = chef.prepare(archive)

Expand Down
7 changes: 4 additions & 3 deletions tests/installation/test_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import json
import re
import shutil

from pathlib import Path
from typing import TYPE_CHECKING
Expand Down Expand Up @@ -1298,13 +1299,13 @@ def test_run_installs_with_local_setuptools_directory(
locker: Locker,
repo: Repository,
package: ProjectPackage,
tmpdir: Path,
tmp_path: Path,
fixture_dir: FixtureDirGetter,
) -> None:
root_dir = Path(__file__).parent.parent.parent
root_dir = tmp_path / "root"
package.root_dir = root_dir
locker.set_lock_path(root_dir)
file_path = fixture_dir("project_with_setup/")
file_path = shutil.copytree(fixture_dir("project_with_setup"), root_dir / "project")
package.add_dependency(
Factory.create_dependency(
"project-with-setup",
Expand Down
Loading

0 comments on commit b8fd4a1

Please sign in to comment.