Commit 549224a2 by Sébastien Eustace

Improve the new command

parent 7a372c75
...@@ -19,6 +19,7 @@ class NewCommand(Command): ...@@ -19,6 +19,7 @@ class NewCommand(Command):
def handle(self): def handle(self):
from poetry.layouts import layout from poetry.layouts import layout
from poetry.semver import parse_constraint
from poetry.utils._compat import Path from poetry.utils._compat import Path
from poetry.utils.env import SystemEnv from poetry.utils.env import SystemEnv
from poetry.vcs.git import GitConfig from poetry.vcs.git import GitConfig
...@@ -55,12 +56,21 @@ class NewCommand(Command): ...@@ -55,12 +56,21 @@ class NewCommand(Command):
default_python = "^{}".format( default_python = "^{}".format(
".".join(str(v) for v in current_env.version_info[:2]) ".".join(str(v) for v in current_env.version_info[:2])
) )
dev_dependencies = {}
python_constraint = parse_constraint(default_python)
if parse_constraint("<3.5").allows_any(python_constraint):
dev_dependencies["pytest"] = "^4.6"
if parse_constraint(">=3.5").allows_all(python_constraint):
dev_dependencies["pytest"] = "^5.2"
layout_ = layout_( layout_ = layout_(
name, name,
"0.1.0", "0.1.0",
author=author, author=author,
readme_format=readme_format, readme_format=readme_format,
python=default_python, python=default_python,
dev_dependencies=dev_dependencies,
) )
layout_.create(path) layout_.create(path)
......
...@@ -63,10 +63,7 @@ class Layout(object): ...@@ -63,10 +63,7 @@ class Layout(object):
self._license = license self._license = license
self._python = python self._python = python
self._dependencies = dependencies or {} self._dependencies = dependencies or {}
if dev_dependencies is None: self._dev_dependencies = dev_dependencies or {}
dev_dependencies = {"pytest": "^3.5"}
self._dev_dependencies = dev_dependencies
if not author: if not author:
author = "Your Name <you@example.com>" author = "Your Name <you@example.com>"
...@@ -131,8 +128,6 @@ class Layout(object): ...@@ -131,8 +128,6 @@ class Layout(object):
readme_file.touch() readme_file.touch()
def _create_tests(self, path): def _create_tests(self, path):
self._dev_dependencies["pytest"] = "^3.0"
tests = path / "tests" tests = path / "tests"
tests_init = tests / "__init__.py" tests_init = tests / "__init__.py"
tests_default = tests / "test_{}.py".format(self._package_name) tests_default = tests / "test_{}.py".format(self._package_name)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment