from cookiecutter.main import is_repo_url, expand_abbreviations


def test_is_repo_url():
    """Verify is_repo_url works."""
    assert is_repo_url('gitolite@server:team/repo') is True
    assert is_repo_url('git@github.com:audreyr/cookiecutter.git') is True
    assert is_repo_url('https://github.com/audreyr/cookiecutter.git') is True
    assert is_repo_url('https://bitbucket.org/pokoli/cookiecutter.hg') is True

    assert is_repo_url('/audreyr/cookiecutter.git') is False
    assert is_repo_url('/home/audreyr/cookiecutter') is False

    appveyor_temp_dir = (
        'c:\\users\\appveyor\\appdata\\local\\temp\\1\\pytest-0\\'
        'test_default_output_dir0\\template'
    )
    assert is_repo_url(appveyor_temp_dir) is False


def test_expand_abbreviations():
    template = 'gh:audreyr/cookiecutter-pypackage'

    # This is not a valid repo url just yet!
    # First `main.expand_abbreviations` needs to translate it
    assert is_repo_url(template) is False

    expanded_template = expand_abbreviations(template, {})
    assert is_repo_url(expanded_template) is True


import pytest

from cookiecutter.main import is_repo_url, expand_abbreviations


@pytest.fixture(params=[
    'gitolite@server:team/repo',
    'git@github.com:audreyr/cookiecutter.git',
    'https://github.com/audreyr/cookiecutter.git',
    'https://bitbucket.org/pokoli/cookiecutter.hg',
])
def remote_repo_url(request):
    return request.param


def test_is_repo_url_for_remote_urls(remote_repo_url):
    """Verify is_repo_url works."""
    assert is_repo_url(remote_repo_url) is True


@pytest.fixture(params=[
    '/audreyr/cookiecutter.git',
    '/home/audreyr/cookiecutter',
    (
        'c:\\users\\appveyor\\appdata\\local\\temp\\1\\pytest-0\\'
        'test_default_output_dir0\\template'
    ),
])
def local_repo_url(request):
    return request.param


def test_is_repo_url_for_local_urls(local_repo_url):
    """Verify is_repo_url works."""
    assert is_repo_url(local_repo_url) is False


def test_expand_abbreviations():
    template = 'gh:audreyr/cookiecutter-pypackage'

    # This is not a valid repo url just yet!
    # First `main.expand_abbreviations` needs to translate it
    assert is_repo_url(template) is False

    expanded_template = expand_abbreviations(template, {})
    assert is_repo_url(expanded_template) is True

Refactor tests for is_repo_url to be parametrized
Refactor tests for is_repo_url to be parametrized

+ 
+ import pytest
+ 
  from cookiecutter.main import is_repo_url, expand_abbreviations
  
  
- def test_is_repo_url():
+ @pytest.fixture(params=[
+     'gitolite@server:team/repo',
+     'git@github.com:audreyr/cookiecutter.git',
+     'https://github.com/audreyr/cookiecutter.git',
+     'https://bitbucket.org/pokoli/cookiecutter.hg',
+ ])
+ def remote_repo_url(request):
+     return request.param
+ 
+ 
+ def test_is_repo_url_for_remote_urls(remote_repo_url):
      """Verify is_repo_url works."""
+     assert is_repo_url(remote_repo_url) is True
-     assert is_repo_url('gitolite@server:team/repo') is True
-     assert is_repo_url('git@github.com:audreyr/cookiecutter.git') is True
-     assert is_repo_url('https://github.com/audreyr/cookiecutter.git') is True
-     assert is_repo_url('https://bitbucket.org/pokoli/cookiecutter.hg') is True
  
-     assert is_repo_url('/audreyr/cookiecutter.git') is False
-     assert is_repo_url('/home/audreyr/cookiecutter') is False
  
-     appveyor_temp_dir = (
+ @pytest.fixture(params=[
+     '/audreyr/cookiecutter.git',
+     '/home/audreyr/cookiecutter',
+     (
          'c:\\users\\appveyor\\appdata\\local\\temp\\1\\pytest-0\\'
          'test_default_output_dir0\\template'
-     )
+     ),
+ ])
+ def local_repo_url(request):
+     return request.param
+ 
+ 
+ def test_is_repo_url_for_local_urls(local_repo_url):
+     """Verify is_repo_url works."""
-     assert is_repo_url(appveyor_temp_dir) is False
+     assert is_repo_url(local_repo_url) is False
  
  
  def test_expand_abbreviations():
      template = 'gh:audreyr/cookiecutter-pypackage'
  
      # This is not a valid repo url just yet!
      # First `main.expand_abbreviations` needs to translate it
      assert is_repo_url(template) is False
  
      expanded_template = expand_abbreviations(template, {})
      assert is_repo_url(expanded_template) is True
  
Refactor tests for is_repo_url to be parametrized
## Code Before:
from cookiecutter.main import is_repo_url, expand_abbreviations


def test_is_repo_url():
    """Verify is_repo_url works."""
    assert is_repo_url('gitolite@server:team/repo') is True
    assert is_repo_url('git@github.com:audreyr/cookiecutter.git') is True
    assert is_repo_url('https://github.com/audreyr/cookiecutter.git') is True
    assert is_repo_url('https://bitbucket.org/pokoli/cookiecutter.hg') is True

    assert is_repo_url('/audreyr/cookiecutter.git') is False
    assert is_repo_url('/home/audreyr/cookiecutter') is False

    appveyor_temp_dir = (
        'c:\\users\\appveyor\\appdata\\local\\temp\\1\\pytest-0\\'
        'test_default_output_dir0\\template'
    )
    assert is_repo_url(appveyor_temp_dir) is False


def test_expand_abbreviations():
    template = 'gh:audreyr/cookiecutter-pypackage'

    # This is not a valid repo url just yet!
    # First `main.expand_abbreviations` needs to translate it
    assert is_repo_url(template) is False

    expanded_template = expand_abbreviations(template, {})
    assert is_repo_url(expanded_template) is True

## Instruction:
Refactor tests for is_repo_url to be parametrized
## Code After:

import pytest

from cookiecutter.main import is_repo_url, expand_abbreviations


@pytest.fixture(params=[
    'gitolite@server:team/repo',
    'git@github.com:audreyr/cookiecutter.git',
    'https://github.com/audreyr/cookiecutter.git',
    'https://bitbucket.org/pokoli/cookiecutter.hg',
])
def remote_repo_url(request):
    return request.param


def test_is_repo_url_for_remote_urls(remote_repo_url):
    """Verify is_repo_url works."""
    assert is_repo_url(remote_repo_url) is True


@pytest.fixture(params=[
    '/audreyr/cookiecutter.git',
    '/home/audreyr/cookiecutter',
    (
        'c:\\users\\appveyor\\appdata\\local\\temp\\1\\pytest-0\\'
        'test_default_output_dir0\\template'
    ),
])
def local_repo_url(request):
    return request.param


def test_is_repo_url_for_local_urls(local_repo_url):
    """Verify is_repo_url works."""
    assert is_repo_url(local_repo_url) is False


def test_expand_abbreviations():
    template = 'gh:audreyr/cookiecutter-pypackage'

    # This is not a valid repo url just yet!
    # First `main.expand_abbreviations` needs to translate it
    assert is_repo_url(template) is False

    expanded_template = expand_abbreviations(template, {})
    assert is_repo_url(expanded_template) is True
