Skip to content

Commit

Permalink
Fix Bug: envname with dash or underscore not detected
Browse files Browse the repository at this point in the history
  • Loading branch information
gtalarico committed May 7, 2018
1 parent 98cde64 commit f8206c9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ History
------------------

* Full Test Suite
* Fixed Envname character bug


0.4.1 (2018-05-02)
Expand Down
2 changes: 1 addition & 1 deletion pipenv_pipes/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

def get_project_name(folder_name):
""" Returns name of a project given a Pipenv Environment folder """
PIPENV_FOLDER_PAT = r'^(.+)-\w{8}$'
PIPENV_FOLDER_PAT = r'^(.+)-[\w_-]{8}$'
match = re.search(PIPENV_FOLDER_PAT, folder_name)
return None if not match else match.group(1)

Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def mock_env_home_empty(TempEnviron, mock_projects_dir):
# TODO: Replace this with an actual pipenv fake env
# that returns valid --venv so we can reduce usage
# of mock_slow
# https://github.com/pypa/pipenv/blob/master/pipenv/project.py#L223
for project_name in os.listdir(mock_projects_dir):
envname = '{}-12345678'.format(project_name)
os.makedirs(os.path.join(pipenv_home, envname))
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def fake_environments():
return [
Environment(
project_name='proj1',
envname='proj1-12345678',
envname='proj1-1C_-wqgW',
envpath='~/fakedir/proj1-12345678'
),
Environment(
Expand All @@ -45,7 +45,7 @@ def fake_environments():
@pytest.mark.utils
@pytest.mark.parametrize("folder_name,expected", [
("nonpipenvproject", None),
("project1-12345678", 'project1'),
("project1-1C_-wqgW", 'project1'),
("something-with-dash-awrasdQW", 'something-with-dash'),
])
def test_get_project_name(folder_name, expected):
Expand Down

0 comments on commit f8206c9

Please sign in to comment.