Repository: cookiecutter/cookiecutter

Issue:
Instructions for local development are incomplete.
When executing the line:

```
python setup.py test
```

as directed, I get the following error:

```
running test
Traceback (most recent call last):
  File "setup.py", line 111, in <module>
    tests_require=test_requirements
  File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "setup.py", line 60, in run
    import pytest
ImportError: No module named pytest
```

I'm not sure what you are supposed to do to install the 'tests_require' dependencies.



Discussion:
That's supposed to happen automatically when running `python setup.py test`. I look into it over the holiday weekend.

I can confirm this issue. :worried: 

It seems to be a problem with our `PyTest` Command. Setuptools comes with a TestCommand that does consider `tests_require` whereas Distutils doesn't. 

@hackebrot Didn't you suggest we get off of `Setuptools` or `Distutils`?

Well, from what I know `setuptools` is a standard pretty much. If we all agree on dropping `distutils`, I will happily integrate `tox` and solve this very issue.

cc @audreyr @pydanny @michaeljoseph 


Resolving patch:
diff --git a/cookiecutter/compat.py b/cookiecutter/compat.py
--- a/cookiecutter/compat.py
+++ b/cookiecutter/compat.py
@@ -8,7 +8,6 @@
 if PY3:  # pragma: no cover
     input_str = 'builtins.input'
     iteritems = lambda d: iter(d.items())
-    from unittest.mock import patch
     from io import StringIO
 
 
@@ -17,7 +16,6 @@
     input = raw_input
     input_str = '__builtin__.raw_input'
     iteritems = lambda d: d.iteritems()
-    from mock import patch
     from cStringIO import StringIO
 
 
@@ -101,4 +99,4 @@ def is_string(obj):
     return isinstance(obj, str if PY3 else basestring)
 
 
-_hush_pyflakes = (patch, StringIO, which)
+_hush_pyflakes = (StringIO, which)
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -4,9 +4,9 @@
 import sys
 
 try:
-    from setuptools import setup, Command
+    from setuptools import setup
 except ImportError:
-    from distutils.core import setup, Command
+    from distutils.core import setup
 
 version = "1.0.0"
 
@@ -33,16 +33,6 @@
     'click<5.0'
 ]
 
-test_requirements = [
-    'pytest'
-]
-
-# Add Python 2.7-specific dependencies
-if sys.version < '3':
-    requirements.append('mock')
-
-# There are no Python 3-specific dependencies to add
-
 long_description = readme + '\n\n' + history
 
 if sys.argv[-1] == 'readme':
@@ -50,21 +40,6 @@
     sys.exit()
 
 
-class PyTest(Command):
-    user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]
-
-    def initialize_options(self):
-        self.pytest_args = []
-
-    def finalize_options(self):
-        pass
-
-    def run(self):
-        import pytest
-        errno = pytest.main(self.pytest_args)
-        sys.exit(errno)
-
-
 setup(
     name='cookiecutter',
     version=version,
@@ -109,7 +84,4 @@ def run(self):
         'skeleton, scaffolding, project directory, setup.py, package, '
         'packaging'
     ),
-    cmdclass = {'test': PyTest},
-    test_suite='tests',
-    tests_require=test_requirements
 )


Test patch:
diff --git a/docs/contributor_testing.rst b/docs/contributor_testing.rst
--- a/docs/contributor_testing.rst
+++ b/docs/contributor_testing.rst
@@ -1,30 +1,23 @@
-Testing
--------
+Testing with tox
+----------------
 
-To run a particular test::
+Tox uses py.test under the hood, hence it supports the same syntax for selecting tests.
 
-    $ python -m unittest tests.test_find.TestFind.test_find_template
+For further information please consult the `pytest usage docs`_.
 
-To run a subset of tests::
+To run a particular test class with tox::
 
-    $ python -m unittest tests.test_find
-
-Testing with py.test
---------------------
-
-To run a particular test class with py.test::
-
-    $ py.test -k TestGetConfig
+    $ tox -e py '-k TestFindHooks'
 
 To run some tests with names matching a string expression::
 
-    $ py.test -k generate
+    $ tox -e py '-k generate'
 
 Will run all tests matching "generate", test_generate_files for example.
 
 To run just one method::
 
-    $ py.test -k TestGetConfig::test_get_config
+    $ tox -e py '-k "TestFindHooks and test_find_hook"'
 
 
 To run all tests using various versions of python in virtualenvs defined in tox.ini, just run tox.::
@@ -51,3 +44,4 @@ Python 3.3 tests fail locally
 Try upgrading Tox to the latest version. I noticed that they were failing
 locally with Tox 1.5 but succeeding when I upgraded to Tox 1.7.1.
 
+.. _`pytest usage docs`: https://pytest.org/latest/usage.html#specifying-tests-selecting-tests