Skip to content

Commit

Permalink
--force now allows non-standard extension names
Browse files Browse the repository at this point in the history
  • Loading branch information
srobuttiteraki authored and chobeat committed Oct 14, 2018
1 parent e03c0aa commit a270b95
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/pyscaffoldext/custom_extension/custom_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@


class InvalidProjectNameException(BaseException):
pass
"""Project name does not comply with convention of an extension"""

DEFAULT_MESSAGE = (
"An extension project name should start with "
"``pyscaffoldext-`` or use ``--force`` to overwrite.")

def __init__(self, message=DEFAULT_MESSAGE, *args, **kwargs):
super().__init__(message, *args, **kwargs)


class CustomExtension(Extension):
Expand Down Expand Up @@ -169,7 +176,7 @@ def check_project_name(struct, opts):
:param opts:
:return:
"""
if not opts['project'].startswith('pyscaffoldext-'):
if not opts['project'].startswith('pyscaffoldext-') and not opts['force']:
raise InvalidProjectNameException("An extension project name"
"should start with "
"'pyscaffoldext-")
Expand Down
10 changes: 10 additions & 0 deletions tests/test_naming_convention.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,13 @@ def test_naming_convention_package_name(tmpfolder):
create_project(opts)
assert not path_exists("pyscaffoldext-some_extension/src/pyscaffoldext/"
"some_extension")


def test_naming_convention_force(tmpfolder):
args = ["--force", "--namespace", "test.second_level",
"--custom-extension", "some_extension"]

opts = parse_args(args)
create_project(opts)
assert not path_exists("pyscaffoldext-some_extension/src/pyscaffoldext/"
"some_extension")

0 comments on commit a270b95

Please sign in to comment.