<commit_before>Django Setuptest
================
**Simple module enabling Django app testing via $ python setup.py test.**


.. contents:: Contents
    :depth: 5

Normally when you execute ``$ python setup.py test`` for Django related
modules you're almost certain to run into ``DJANGO_SETTINGS_MODULE``
environment variable issues, e.g.::

    ImportError: Settings cannot be imported, because environment variable
    DJANGO_SETTINGS_MODULE is undefined.

This module overcomes this by configuring the ``DJANGO_SETTINGS_MODULE``
environment variable before executing your test suite. As a bonus it also
generates Coverage_ and `PEP 8`_ reports as part of the test.


Installation
------------

#. Provide a ``cmdclass`` ``test`` argument to the setup call specifying the
   ``setuptest.test`` command, e.g.::
    
    from setuptest import test

    #...

    setup(
        # ...
        cmdclass={'test': test},
    )

   This overrides Python's builtin ``test`` command to enable the Django 
   testrunner as well as allowing you to pass ``--failfast`` as a commandline
   argument, i.e.::

    $ python setup.py test --failfast

   Alternatively you can specify a ``test_suite`` argument to the 
   setup call specifying the ``setuptest.setuptest.SetupTestSuite`` test 
   suite, e.g.::

    setup(
        # ...
        test_suite='setuptest.setuptest.SetupTestSuite',
    )

#. Provide a ``tests_require`` argument to the setup call including
   ``django-setuptest`` (required) and other package dependencies needed
   to execute the tests, e.g.::

    setup(
        # ...
        tests_require=(
            'django-setuptest',
        ),
    )

#. Specify your test specific Django settings in a ``test_settings``
   module in the same path as your app's ``setup.py``.
   These settings will be used when executing the tests, e.g. in
   ``test_settings.py``::

    DATABASE_ENGINE = 'sqlite3'

    INSTALLED_APPS = (
        'myapp',
    )

#. In order for the test suite to find your tests you must provide either a 
   ``packages`` or ``py_modules`` argument to the setup call, e.g.::

    from setuptools import setup, find_packages
    
    setup(
        # ...<commit_msg>note on installation requirement for cmdclass method<commit_after>Django Setuptest
================
**Simple module enabling Django app testing via $ python setup.py test.**


.. contents:: Contents
    :depth: 5

Normally when you execute ``$ python setup.py test`` for Django related
modules you're almost certain to run into ``DJANGO_SETTINGS_MODULE``
environment variable issues, e.g.::

    ImportError: Settings cannot be imported, because environment variable
    DJANGO_SETTINGS_MODULE is undefined.

This module overcomes this by configuring the ``DJANGO_SETTINGS_MODULE``
environment variable before executing your test suite. As a bonus it also
generates Coverage_ and `PEP 8`_ reports as part of the test.


Installation
------------

#. Provide a ``test_suite`` argument to the setup call specifying the 
   ``setuptest.setuptest.SetupTestSuite`` test suite, e.g.::

    setup(
        # ...
        test_suite='setuptest.setuptest.SetupTestSuite',
    )

   Alternatively provide a ``cmdclass`` ``test`` argument to the setup call 
   specifying the ``setuptest.test`` command, e.g.::
    
    from setuptest import test

    #...

    setup(
        # ...
        cmdclass={'test': test},
    )

   This overrides Python's builtin ``test`` command to enable the Django 
   testrunner as well as allowing you to pass ``--failfast`` as a commandline
   argument, i.e.::

    $ python setup.py test --failfast

   For the ``cmdclass`` method to work ``django-setuptools`` should be 
   installed and available in your Python path prior to running the ``test`` 
   command.

#. Provide a ``tests_require`` argument to the setup call including
   ``django-setuptest`` (required) and other package dependencies needed
   to execute the tests, e.g.::

    setup(
        # ...
        tests_require=(
            'django-setuptest',
        ),
    )

#. Specify your test specific Django settings in a ``test_settings``
   module in the same path as your app's ``setup.py``.
   These settings will be used when executing the tests, e.g. in
   ``test_settings.py``::

    DATABASE_ENGINE = 'sqlite3'

    INSTALLED_APPS = (
        'myapp',
    )

#. In order for the test suite to find your tests you must provide either a 
   ``packages`` or ``py_modules`` argument to the setup call, e.g.::

    from setuptools import setup, find_packages
    
    setup(
        # ...
{'fraction_non_alphanumeric': 0.10816728705933873, 'fraction_numerical': 0.0013137727173199037, 'mean_word_length': 2.9652777777777777, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2578083', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1266, 'n_words': 502}