Skip to content

Commit

Permalink
Fix test cases to eliminate extra warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
frostming committed Aug 3, 2021
1 parent 5de9035 commit 29b6e62
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,4 @@ markers = [
"pypi: Tests that connect to the real PyPI",
"integration: Run with all Python versions"
]
addopts = "-ra"
15 changes: 11 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import re
import shutil
import sys
from distutils.dir_util import copy_tree
from io import BytesIO
from pathlib import Path
from typing import Callable, Iterable, List, Tuple
Expand Down Expand Up @@ -108,8 +107,6 @@ def _get_dependencies_from_fixture(
except KeyError:
raise CandidateInfoNotFound(candidate)
deps = pypi_data.get("dependencies", [])
for extra in candidate.req.extras or ():
deps.extend(pypi_data.get("extras_require", {}).get(extra, []))
deps = filter_requirements_with_extras(deps, candidate.req.extras or ())
return deps, pypi_data.get("requires_python", ""), ""

Expand Down Expand Up @@ -269,13 +266,23 @@ def project(project_no_init):
return project_no_init


def copytree(src: Path, dst: Path) -> None:
if not dst.exists():
dst.mkdir(parents=True)
for subpath in src.iterdir():
if subpath.is_dir():
copytree(subpath, dst / subpath.name)
else:
shutil.copy2(subpath, dst)


@pytest.fixture()
def fixture_project(project_no_init):
"""Initailize a project from a fixture project"""

def func(project_name):
source = FIXTURES / "projects" / project_name
copy_tree(source.as_posix(), project_no_init.root.as_posix())
copytree(source, project_no_init.root)
project_no_init._pyproject = None
return project_no_init

Expand Down
31 changes: 14 additions & 17 deletions tests/fixtures/pypi.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,20 @@
"certifi>=2017.4.17",
"chardet<3.1.0,>=3.0.2",
"idna<2.8,>=2.5",
"urllib3<1.24,>=1.21.1"
],
"extras_require": {
"socks": ["PySocks>=1.5.6,!=1.5.7"],
"security": ["pyOpenSSL>=0.14"]
}
"urllib3<1.24,>=1.21.1",
"PySocks>=1.5.6,!=1.5.7; extra=='socks'",
"pyOpenSSL>=0.14; extra=='security'"
]
},
"2.20.0b1": {
"dependencies": [
"certifi>=2017.4.17",
"chardet<3.1.0,>=3.0.2",
"idna<2.8,>=2.5",
"urllib3<1.24,>=1.23b0"
],
"extras_require": {
"socks": ["PySocks>=1.5.6,!=1.5.7"],
"security": ["pyOpenSSL>=0.14"]
}
"urllib3<1.24,>=1.23b0",
"PySocks>=1.5.6,!=1.5.7; extra=='socks'",
"pyOpenSSL>=0.14; extra=='security'"
]
}
},
"urllib3": { "1.22": {}, "1.23b0": {} },
Expand All @@ -45,11 +41,12 @@
"demo": {
"0.0.1": {
"requires_python": ">=3.3",
"dependencies": ["idna", "chardet; os_name=='nt'"],
"extras_require": {
"tests": ["pytest"],
"security": ["requests; python_version>='3.6'"]
}
"dependencies": [
"idna",
"chardet; os_name=='nt'",
"pytest; extra=='tests'",
"requests; python_version>='3.6' and extra=='security'"
]
}
},
"django-toolbar": {
Expand Down

0 comments on commit 29b6e62

Please sign in to comment.