Skip to content
This repository has been archived by the owner on Jan 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #141 from dbanty/hotfix/project_test
Browse files Browse the repository at this point in the history
Hotfix/project test
  • Loading branch information
orsinium committed Nov 19, 2019
2 parents 9619392 + e1204b2 commit db945b1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
8 changes: 7 additions & 1 deletion dephell/controllers/_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
logger = getLogger('dephell.controllers')
# regex for names generated by pipenv
rex_hash = re.compile(r'[a-f0-9]{7}')
rex_vers = re.compile(r'[a-z_-]+\-[0-9.]+')


class DependencyMaker:
Expand Down Expand Up @@ -59,8 +60,13 @@ def from_requirement(cls, source, req, *, url=None, envs=None, marker: Union[Mar
if source.repo and source.repo.propagate:
default_repo = source.repo

name = req.name
# drop version from the end
if rex_vers.fullmatch(name):
name = name.rsplit('-', maxsplit=1)[0]

base_dep = cls.dep_class(
raw_name=req.name,
raw_name=name,
constraint=constraint,
repo=get_repo(link, default=default_repo),
link=link,
Expand Down
16 changes: 10 additions & 6 deletions dephell/converters/flit.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,16 @@ def dumps(self, reqs, project: RootDependency, content=None) -> str:
section = doc['tool']['flit']['metadata']

# project and module names
module = project.package.packages[0].module
section['module'] = module
if project.raw_name != module:
section['dist-name'] = project.raw_name
elif 'dist-name' in section:
del section['dist-name']
packages = project.package.packages
if packages:
module = packages[0].module
section['module'] = module
if project.raw_name != module:
section['dist-name'] = project.raw_name
elif 'dist-name' in section:
del section['dist-name']
else:
section['module'] = project.raw_name

# author and maintainer
for field, author in zip(('author', 'maintainer'), project.authors):
Expand Down
1 change: 1 addition & 0 deletions tests/test_commands/test_inspect_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def test_inspect_project_command(temp_path: Path, requirements_path: Path, capsy
'from': {'format': 'poetry', 'path': from_path},
'project': str(temp_path),
'nocolors': True,
'silent': True,
})

command = InspectProjectCommand(argv=[], config=config)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_converters/test_imports.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from pathlib import Path

# external
import pytest

Expand All @@ -21,6 +23,7 @@ def test_imports_parser(lines, expected):
assert modules == expected


@pytest.mark.skipif(not Path('dephell').exists(), reason='dephell source dir does not exist')
@pytest.mark.allow_hosts()
def test_imports_load():
converter = ImportsConverter()
Expand Down
4 changes: 4 additions & 0 deletions tests/test_repositories/test_git_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@


loop = asyncio.get_event_loop()
git_path = Path('.git')


class PatchedVCSLink(VCSLink):
Expand All @@ -23,6 +24,7 @@ class Dep:


@pytest.mark.skipif('TRAVIS_OS_NAME' in environ, reason='Travis CI has broken git repo')
@pytest.mark.skipif(not git_path.exists(), reason='.git folder does not exist')
def test_releases():
link = PatchedVCSLink(server=None, author=None, project=None, name='dephell')
repo = GitRepo(link)
Expand All @@ -37,6 +39,7 @@ def test_releases():


@pytest.mark.skipif('TRAVIS_OS_NAME' in environ, reason='Travis CI has broken git repo')
@pytest.mark.skipif(not git_path.exists(), reason='.git folder does not exist')
def test_deps():
link = PatchedVCSLink(server=None, author=None, project=None, name='dephell')
repo = GitRepo(link)
Expand All @@ -48,6 +51,7 @@ def test_deps():


@pytest.mark.skipif('TRAVIS_OS_NAME' in environ, reason='Travis CI has broken git repo')
@pytest.mark.skipif(not git_path.exists(), reason='.git folder does not exist')
def test_metaversion():
link = PatchedVCSLink(server=None, author=None, project=None, name='dephell')
repo = GitRepo(link)
Expand Down

0 comments on commit db945b1

Please sign in to comment.