{ "info": { "author": "Eric Davis", "author_email": "ed@npri.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Software Development :: Testing" ], "description": "========================\ndjango-override-settings\n========================\n\ndjango-override-settings provides an easy way to override settings in\nDjango tests.\n\nThe ``override_settings`` class can be used as either a class or\nmethod decorator or as a context manager to temporarily override the\nvalues of settings. After each test case has finished (when using it\nas a decorator) or after the context manager has exited, it resets the\nvalues in ``django.conf.settings`` to what they were before. This prevents\nside-effects from creeping in and lets each test case run in its own\nsandbox.\n\nThis package also provides two convenience functions (``with_apps``\nand ``without_apps``) to modify just ``INSTALLED_APPS`` as well as a\nspecial object (``SETTING_DELETED``) to run tests without a given\nsetting defined.\n\nThe functionality in this package will eventually be superseded when\nDjango 1.4 is released as it will come with a built-in\n``override_settings``. But for those maintaining pre-1.4 codebases,\nhopefully this package comes in handy.\n\nInstallation\n------------\n\nWe're on PyPI_::\n\n pip install django-override-settings\n\n.. _PyPI: http://pypi.python.org/pypi/django-override-settings\n\nUsage\n-----\n\nIf you have a bunch of tests that require a given setting, you can\ndecorate the class and each test case will use that value. For\nexample::\n\n from django.conf import settings\n from django.test import TestCase\n from override_settings import override_settings\n\n @override_settings(FOO=\"abc\")\n class TestFoo(TestCase):\n def test_foo(self):\n self.assertEqual(settings.FOO, \"abc\")\n\nOr you can decorate a single test case and have it only apply on that\nmethod::\n\n @override_settings(BAR=\"123\")\n class TestBar(TestCase):\n\n @override_settings(BAR=\"abc\")\n def test_bar(self):\n self.assertEqual(settings.BAR, \"abc\")\n\n def test_bar_no_decoration(self):\n self.assertEqual(settings.BAR, \"123\")\n\nYou can also use it as a context manager::\n\n class TestBar(TestCase):\n @override_settings(BAR=\"123\")\n def test_bar(self):\n self.assertEqual(settings.BAR, \"123\")\n\n with override_settings(BAR=\"abc\")\n self.assertEqual(settings.BAR, \"abc\")\n\n self.assertEqual(settings.BAR, \"123\")\n\nTo modify just ``INSTALLED_APPS``, use ``with_apps`` or\n``without_apps``::\n\n from override_settings import with_apps, without_apps\n\n class TestAppModifiers(TestCase):\n @with_apps('django.contrib.humanize')\n def test_humanize(self):\n # ...\n\n @without_apps('django.contrib.sites')\n def test_no_sites(self):\n # ...\n\nTo run tests without a setting, use ``SETTING_DELETED``::\n\n from override_settings import override_settings, SETTING_DELETED\n\n class TestMissingSetting(TestCase):\n @override_settings(CUSTOM_OPTION=SETTING_DELETED)\n def test_delete_custom_option(self):\n \"\"\"\n Useful to make sure a missing setting raises an Exception.\n \"\"\"\n self.assertRaises(AttributeError, getattr, settings, 'CUSTOM_OPTION')\n\nRequirements\n------------\n\n- Django >= 1.2\n\nThanks\n------\n\n- `Jannis Leidel`_ for both the `original snippet`_ and his work updating it\n to work when decorating TestCases as part of `Django proper`_.\n\n- `Joost Cassee`_ for the idea of ``SETTING_DELETED`` as well as\n ``with_apps`` and ``without_apps`` as part of his django-analytical_\n project.\n\n.. _Jannis Leidel: https://github.com/jezdez\n.. _original snippet: http://djangosnippets.org/snippets/2437/\n.. _Django proper: https://code.djangoproject.com/browser/django/trunk/django/test/utils.py\n.. _Joost Cassee: https://github.com/jcassee\n.. _django-analytical: https://github.com/jcassee/django-analytical\n\nContact\n-------\n\nIf you notice any bugs, please `open a ticket`_.\n\n.. _open a ticket: https://github.com/edavis/django-override-settings/issues", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/edavis/django-override-settings/", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "django-override-settings", "package_url": "https://pypi.org/project/django-override-settings/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-override-settings/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/edavis/django-override-settings/" }, "release_url": "https://pypi.org/project/django-override-settings/1.2/", "requires_dist": null, "requires_python": null, "summary": "Provide a way to override Django's settings when running tests", "version": "1.2" }, "last_serial": 748620, "releases": { "1.1": [ { "comment_text": "", "digests": { "md5": "da3281418a5d73ab7c0bea434e6179fe", "sha256": "23bf15892abfefccf818e4a76272c0e8037d09edae4650d7acdb81113571131b" }, "downloads": -1, "filename": "django-override-settings-1.1.tar.gz", "has_sig": false, "md5_digest": "da3281418a5d73ab7c0bea434e6179fe", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4153, "upload_time": "2011-07-06T20:16:54", "url": "https://files.pythonhosted.org/packages/fd/a5/b56bd6080c2a7ff436d64326709749c90169b92a51b588bf60bffba0df36/django-override-settings-1.1.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "db5b8424484107744bf1798615528e84", "sha256": "10a8074496e10f571d4b6a5df2a05bde259dcde434543c0383180cfb0200d322" }, "downloads": -1, "filename": "django-override-settings-1.1.1.tar.gz", "has_sig": false, "md5_digest": "db5b8424484107744bf1798615528e84", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4505, "upload_time": "2011-09-09T21:01:32", "url": "https://files.pythonhosted.org/packages/fd/bf/a0316e66f5600dea9baa8d424a303a9471ba0aef1e7c0a54162b4656e0d3/django-override-settings-1.1.1.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "f1becffe14c6645e049c321bf119edb7", "sha256": "375f0d86c199436054a22e7933fc0e9e59affb6dc8fea0a726de3850aa1d9de8" }, "downloads": -1, "filename": "django-override-settings-1.2.tar.gz", "has_sig": false, "md5_digest": "f1becffe14c6645e049c321bf119edb7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4482, "upload_time": "2011-09-12T18:57:07", "url": "https://files.pythonhosted.org/packages/e2/6f/63f10bab3d1435c2848f1b3a3c91c9bfd40f627ad95bb3c1a81040478fc8/django-override-settings-1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f1becffe14c6645e049c321bf119edb7", "sha256": "375f0d86c199436054a22e7933fc0e9e59affb6dc8fea0a726de3850aa1d9de8" }, "downloads": -1, "filename": "django-override-settings-1.2.tar.gz", "has_sig": false, "md5_digest": "f1becffe14c6645e049c321bf119edb7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4482, "upload_time": "2011-09-12T18:57:07", "url": "https://files.pythonhosted.org/packages/e2/6f/63f10bab3d1435c2848f1b3a3c91c9bfd40f627ad95bb3c1a81040478fc8/django-override-settings-1.2.tar.gz" } ] }