From 14520324d9db3c9201a1984a5cab8ab8d2a2667b Mon Sep 17 00:00:00 2001 From: Rick van Hattem Date: Thu, 5 Apr 2018 22:57:47 +0200 Subject: [PATCH] updated to django 1.11 and django 2.0 --- .travis.yml | 29 +- django_statsd/__about__.py | 10 + django_statsd/middleware.py | 21 +- docs/{_themes => _theme}/LICENSE | 0 .../flask_theme_support.py | 0 docs/{_themes => _theme}/wolph/layout.html | 13 +- docs/{_themes => _theme}/wolph/relations.html | 0 .../wolph/static/flasky.css_t | 0 .../wolph/static/small_flask.css | 0 docs/{_themes => _theme}/wolph/theme.conf | 0 docs/conf.py | 251 +++++++++--------- docs/requirements.txt | 3 +- pytest.ini | 2 +- setup.cfg | 3 - setup.py | 81 +++--- tests/requirements.txt | 9 +- tests/settings.py | 2 +- tests/test_app/urls.py | 7 +- tests/test_prefix.py | 6 +- tests/urls.py | 8 +- tox.ini | 38 ++- 21 files changed, 248 insertions(+), 235 deletions(-) create mode 100644 django_statsd/__about__.py rename docs/{_themes => _theme}/LICENSE (100%) rename docs/{_themes => _theme}/flask_theme_support.py (100%) rename docs/{_themes => _theme}/wolph/layout.html (55%) rename docs/{_themes => _theme}/wolph/relations.html (100%) rename docs/{_themes => _theme}/wolph/static/flasky.css_t (100%) rename docs/{_themes => _theme}/wolph/static/small_flask.css (100%) rename docs/{_themes => _theme}/wolph/theme.conf (100%) diff --git a/.travis.yml b/.travis.yml index efa8b71..05308be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,20 +1,21 @@ sudo: false +cache: pip language: python -python: - - "2.6" - - "2.7" - - "3.3" - - "3.4" - - "pypy" - - "pypy3" +python: 3.6 -# command to install dependencies -install: - - pip install . - - pip install -r tests/requirements.txt +env: + - TOX_ENV=pypy-django11 + - TOX_ENV=py27-django11 + - TOX_ENV=py35-django11 + - TOX_ENV=py35-django20 + - TOX_ENV=py36-django11 + - TOX_ENV=py36-django20 + - TOX_ENV=flake8 + - TOX_ENV=docs -before_script: flake8 --ignore=W391 django_statsd tests +install: + - pip install tox -# command to run tests -script: python setup.py test +script: + tox -e $TOX_ENV diff --git a/django_statsd/__about__.py b/django_statsd/__about__.py new file mode 100644 index 0000000..a91d3e7 --- /dev/null +++ b/django_statsd/__about__.py @@ -0,0 +1,10 @@ +__package_name__ = 'django-statsd' +__version__ = '2.1.1' +__author__ = 'Rick van Hattem' +__author_email__ = 'Rick.van.Hattem@Fawo.nl' +__description__ = ( + '''django-statsd is a Django app that submits query and view durations ''' + '''to Etsy's statsd.''' +) +__url__ = 'https://github.com/WoLpH/django-statsd' + diff --git a/django_statsd/middleware.py b/django_statsd/middleware.py index 15cf3b5..c038703 100644 --- a/django_statsd/middleware.py +++ b/django_statsd/middleware.py @@ -7,6 +7,7 @@ import collections import statsd +from django.utils import deprecation from django.core import exceptions from . import utils @@ -121,10 +122,11 @@ def __call__(self, key): return WithTimer(self, key) -class StatsdMiddleware(object): +class StatsdMiddleware(deprecation.MiddlewareMixin): scope = threading.local() - def __init__(self): + def __init__(self, get_response): + deprecation.MiddlewareMixin.__init__(self, get_response) self.scope.timings = None self.scope.counter = None @@ -217,7 +219,7 @@ def cleanup(self, request): request.statsd = None -class StatsdMiddlewareTimer(object): +class StatsdMiddlewareTimer(deprecation.MiddlewareMixin): def process_request(self, request): if settings.STATSD_TRACK_MIDDLEWARE: @@ -242,19 +244,6 @@ def process_template_response(self, request, response): return response -class TimingMiddleware(StatsdMiddleware): - - @classmethod - def deprecated(cls, *args, **kwargs): - warnings.warn( - 'The `TimingMiddleware` has been deprecated in favour of ' - 'the `StatsdMiddleware`. Please update your middleware settings', - DeprecationWarning - ) - - __init__ = deprecated - - class DummyWith(object): def __enter__(self): diff --git a/docs/_themes/LICENSE b/docs/_theme/LICENSE similarity index 100% rename from docs/_themes/LICENSE rename to docs/_theme/LICENSE diff --git a/docs/_themes/flask_theme_support.py b/docs/_theme/flask_theme_support.py similarity index 100% rename from docs/_themes/flask_theme_support.py rename to docs/_theme/flask_theme_support.py diff --git a/docs/_themes/wolph/layout.html b/docs/_theme/wolph/layout.html similarity index 55% rename from docs/_themes/wolph/layout.html rename to docs/_theme/wolph/layout.html index 4d50f1e..a39162f 100644 --- a/docs/_themes/wolph/layout.html +++ b/docs/_theme/wolph/layout.html @@ -9,19 +9,8 @@ {% endblock %} {%- block relbar2 %}{% endblock %} {%- block footer %} - - {%- endblock %} diff --git a/docs/_themes/wolph/relations.html b/docs/_theme/wolph/relations.html similarity index 100% rename from docs/_themes/wolph/relations.html rename to docs/_theme/wolph/relations.html diff --git a/docs/_themes/wolph/static/flasky.css_t b/docs/_theme/wolph/static/flasky.css_t similarity index 100% rename from docs/_themes/wolph/static/flasky.css_t rename to docs/_theme/wolph/static/flasky.css_t diff --git a/docs/_themes/wolph/static/small_flask.css b/docs/_theme/wolph/static/small_flask.css similarity index 100% rename from docs/_themes/wolph/static/small_flask.css rename to docs/_theme/wolph/static/small_flask.css diff --git a/docs/_themes/wolph/theme.conf b/docs/_theme/wolph/theme.conf similarity index 100% rename from docs/_themes/wolph/theme.conf rename to docs/_theme/wolph/theme.conf diff --git a/docs/conf.py b/docs/conf.py index e742298..95dde69 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- # -# This file is execfile()d with the current directory set to its -# containing dir. +# This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. @@ -13,28 +12,30 @@ import sys import datetime +os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings' + # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath('..')) -import setup as metadata +# sys.path.insert(0, os.path.join(os.path.abspath(os.path.pardir), 'tests')) +sys.path.insert(0, os.path.abspath(os.path.pardir)) +from django_statsd import __about__ + +import django +django.setup() -# -- General configuration ------------------------------------------------ +# -- General configuration ----------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +# needs_sphinx = '1.0' -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', - 'sphinx.ext.todo', 'sphinx.ext.coverage', - 'sphinx.ext.mathjax', - 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode', ] @@ -45,16 +46,16 @@ source_suffix = '.rst' # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. -project = metadata.__package_name__.replace('-', ' ').capitalize() +project = __about__.__package_name__.replace('-', ' ').capitalize() copyright = u'%s, %s' % ( datetime.date.today().year, - metadata.__author__, + __about__.__author__, ) # The version info for the project you're documenting, acts as replacement for @@ -62,50 +63,64 @@ # built documents. # # The short X.Y version. -version = metadata.__version__ +version = __about__.__version__ # The full version, including alpha/beta/rc tags. -release = metadata.__version__ +release = __about__.__version__ + +# Monkey patch to disable nonlocal image warning +import sphinx +if hasattr(sphinx, 'environment'): + original_warn_mode = sphinx.environment.BuildEnvironment.warn_node + + def allow_nonlocal_image_warn_node(self, msg, *args, **kwargs): + if not msg.startswith('nonlocal image URI found:'): + original_warn_mode(self, msg, *args, **kwargs) + + sphinx.environment.BuildEnvironment.warn_node = \ + allow_nonlocal_image_warn_node + +suppress_warnings = [ + 'image.nonlocal_uri', +] + +needs_sphinx = '1.4' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -#language = None +# language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] -# The reST default role (used for this markup: `text`) to use for all -# documents. -#default_role = None +# The reST default role (used for this markup: `text`) to use for all documents. +# default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -#keep_warnings = False +# modindex_common_prefix = [] -# -- Options for HTML output ---------------------------------------------- +# -- Options for HTML output --------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. @@ -114,239 +129,213 @@ # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -#html_theme_options = {} +# html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -html_theme_path = ['_themes'] +html_theme_path = ['_theme'] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None +# html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. -#html_logo = None +# html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -#html_favicon = None +# html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] -# Add any extra paths that contain custom files (such as robots.txt or -# .htaccess) here, relative to this directory. These files are copied -# directly to the root of the documentation. -#html_extra_path = [] - # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +# html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True +# html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True +# html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True +# html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -#html_use_opensearch = '' +# html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = metadata.__package_name__ + '-doc' +htmlhelp_basename = __about__.__package_name__ + '-doc' -# -- Options for LaTeX output --------------------------------------------- +# -- Options for LaTeX output -------------------------------------------- latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', + # The paper size ('letterpaper' or 'a4paper'). + #'papersize': 'letterpaper', -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', + # The font size ('10pt', '11pt' or '12pt'). + #'pointsize': '10pt', -# Additional stuff for the LaTeX preamble. -#'preamble': '', + # Additional stuff for the LaTeX preamble. + #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [( 'index', - '%s.tex' % metadata.__package_name__, - u'%s Documentation' % metadata.__package_name__.replace('-', ' ').capitalize(), - metadata.__author__, + '%s.tex' % __about__.__package_name__, + u'%s Documentation' % __about__.__package_name__.replace('-', ' ').capitalize(), + __about__.__author__, 'manual', -)] + )] # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. -#latex_use_parts = False +# latex_use_parts = False # If true, show page references after internal links. -#latex_show_pagerefs = False +# latex_show_pagerefs = False # If true, show URL addresses after external links. -#latex_show_urls = False +# latex_show_urls = False # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_domain_indices = True +# latex_domain_indices = True -# -- Options for manual page output --------------------------------------- +# -- Options for manual page output -------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [( 'index', - metadata.__package_name__, - u'%s Documentation' % metadata.__package_name__.replace('-', ' ').capitalize(), - [metadata.__author__], + __about__.__package_name__, + u'%s Documentation' % __about__.__package_name__.replace('-', ' ').capitalize(), + [__about__.__author__], 1, )] # If true, show URL addresses after external links. -#man_show_urls = False +# man_show_urls = False -# -- Options for Texinfo output ------------------------------------------- +# -- Options for Texinfo output ------------------------------------------ # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [( 'index', - metadata.__package_name__, - u'%s Documentation' % metadata.__package_name__.replace('-', ' ').capitalize(), - metadata.__author__, - metadata.__package_name__, - metadata.__description__, + __about__.__package_name__, + u'%s Documentation' % __about__.__package_name__.replace('-', ' ').capitalize(), + __about__.__author__, + __about__.__package_name__, + __about__.__description__, 'Miscellaneous', )] # Documents to append as an appendix to all manuals. -#texinfo_appendices = [] +# texinfo_appendices = [] # If false, no module index is generated. -#texinfo_domain_indices = True +# texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -#texinfo_no_detailmenu = False +# texinfo_show_urls = 'footnote' -# -- Options for Epub output ---------------------------------------------- +# -- Options for Epub output --------------------------------------------- # Bibliographic Dublin Core info. -epub_title = metadata.__package_name__.replace('-', ' ').capitalize() -epub_author = metadata.__author__ -epub_publisher = metadata.__author__ +epub_title = __about__.__package_name__.replace('-', ' ').capitalize() +epub_author = __about__.__author__ +epub_publisher = __about__.__author__ epub_copyright = copyright -# The basename for the epub file. It defaults to the project name. -#epub_basename = u'Django Admin Generator' - -# The HTML theme for the epub output. Since the default themes are not optimized -# for small screen space, using the same theme for HTML and epub output is -# usually not wise. This defaults to 'epub', a theme designed to save visual -# space. -#epub_theme = 'epub' - # The language of the text. It defaults to the language option # or en if the language is not set. -#epub_language = '' +# epub_language = '' # The scheme of the identifier. Typical schemes are ISBN or URL. -#epub_scheme = '' +# epub_scheme = '' # The unique identifier of the text. This can be a ISBN number # or the project homepage. -#epub_identifier = '' +# epub_identifier = '' # A unique identification for the text. -#epub_uid = '' +# epub_uid = '' # A tuple containing the cover image and cover page html template filenames. -#epub_cover = () - -# A sequence of (type, uri, title) tuples for the guide element of content.opf. -#epub_guide = () +# epub_cover = () # HTML files that should be inserted before the pages created by sphinx. # The format is a list of tuples containing the path and title. -#epub_pre_files = [] +# epub_pre_files = [] # HTML files shat should be inserted after the pages created by sphinx. # The format is a list of tuples containing the path and title. -#epub_post_files = [] +# epub_post_files = [] # A list of files that should not be packed into the epub file. -epub_exclude_files = ['search.html'] +# epub_exclude_files = [] # The depth of the table of contents in toc.ncx. -#epub_tocdepth = 3 +# epub_tocdepth = 3 # Allow duplicate toc entries. -#epub_tocdup = True - -# Choose between 'default' and 'includehidden'. -#epub_tocscope = 'default' - -# Fix unsupported image types using the PIL. -#epub_fix_images = False - -# Scale large images. -#epub_max_image_width = 0 - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -#epub_show_urls = 'inline' - -# If false, no index is generated. -#epub_use_index = True +# epub_tocdup = True # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'http://docs.python.org/': None} +intersphinx_mapping = { + 'python': ('http://docs.python.org/2', None), + 'pythonutils': ('http://python-utils.readthedocs.io/en/latest/', None), + 'numpy': ('http://docs.scipy.org/doc/numpy/', None), + 'scipy': ('http://docs.scipy.org/doc/scipy/reference/', None), + 'matplotlib': ('http://matplotlib.sourceforge.net/', None), + 'django': ('http://docs.djangoproject.com/en/dev/', + 'http://docs.djangoproject.com/en/dev/_objects/'), +} + diff --git a/docs/requirements.txt b/docs/requirements.txt index 6ca36d5..111b571 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,2 +1 @@ --r../tests/requirements.txt -sphinx +-e.[docs] diff --git a/pytest.ini b/pytest.ini index fe147a0..da3bd86 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,7 +1,7 @@ [pytest] python_files = django_statsd/*.py - test_project/*.py + tests/*.py addopts = --cov django_statsd diff --git a/setup.cfg b/setup.cfg index b69f347..5257e7f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,6 +8,3 @@ all_files = 1 [upload_sphinx] upload-dir = docs/_build/html - -[aliases] -test=pytest diff --git a/setup.py b/setup.py index 88f2fe5..034359f 100644 --- a/setup.py +++ b/setup.py @@ -1,45 +1,66 @@ import os +import sys import setuptools +from setuptools.command.test import test as TestCommand + +# To prevent importing about and thereby breaking the coverage info we use this +# exec hack +about = {} +with open('django_statsd/__about__.py') as fp: + exec(fp.read(), about) -__package_name__ = 'django-statsd' -__version__ = '2.1.1' -__author__ = 'Rick van Hattem' -__author_email__ = 'Rick.van.Hattem@Fawo.nl' -__description__ = '''django-statsd is a django app that submits query and - view durations to Etsy's statsd.''' -__url__ = 'https://github.com/WoLpH/django-statsd' if os.path.isfile('README.rst'): long_description = open('README.rst').read() else: - long_description = 'See http://pypi.python.org/pypi/%s/' % ( - __package_name__) + long_description = ('See http://pypi.python.org/pypi/' + + about['__package_name__']) + + +class PyTest(TestCommand): + def finalize_options(self): + TestCommand.finalize_options(self) + self.test_args = [] + self.test_suite = True + + def run_tests(self): + # import here, cause outside the eggs aren't loaded + import pytest + errno = pytest.main(self.test_args) + sys.exit(errno) if __name__ == '__main__': setuptools.setup( - name=__package_name__, - version=__version__, - author=__author__, - author_email=__author_email__, - description=__description__, - url=__url__, + name=about['__package_name__'], + version=about['__version__'], + author=about['__author__'], + author_email=about['__author_email__'], + description=about['__description__'], + url=about['__url__'], license='BSD', - packages=setuptools.find_packages(exclude=['tests', 'tests.*']), - long_description=long_description, - tests_require=[ - 'pytest', - 'pytest-cache', - 'pytest-cov', - 'pytest-django', - 'flake8', - 'django<1.6', - 'mock', - ], - setup_requires=['setuptools', 'pytest-runner'], - install_requires=['python-statsd>=1.7.2'], - classifiers=[ - 'License :: OSI Approved :: BSD License', + packages=setuptools.find_packages(exclude=['tests']), + install_requires=[ + 'python-statsd>=1.7.2', ], + extras_require={ + 'docs': [ + 'django>=1.11', + 'mock', + 'sphinx>=1.7.2', + ], + 'tests': [ + 'mock', + 'pytest', + 'pytest-cache', + 'pytest-cov', + 'pytest-django', + 'pytest-flakes', + 'pytest-pep8', + ], + }, + long_description=long_description, + cmdclass={'test': PyTest}, + classifiers=['License :: OSI Approved :: BSD License'], ) diff --git a/tests/requirements.txt b/tests/requirements.txt index b2f76ef..9628e3f 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,8 +1 @@ -python-statsd -pytest -pytest-cache -pytest-cov -pytest-django -flake8 -django<1.6 -mock +-e.[tests] diff --git a/tests/settings.py b/tests/settings.py index 4c6314a..d953402 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -85,7 +85,7 @@ 'django.template.loaders.app_directories.Loader', ) -MIDDLEWARE_CLASSES = ( +MIDDLEWARE = ( 'django_statsd.middleware.StatsdMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', diff --git a/tests/test_app/urls.py b/tests/test_app/urls.py index 3113b76..e1f06ae 100644 --- a/tests/test_app/urls.py +++ b/tests/test_app/urls.py @@ -1,5 +1,6 @@ from django.conf import urls +from . import views -urlpatterns = urls.patterns('tests.test_app.views', - urls.url(r'^$', 'index', name='index'), - ) +urlpatterns = [ + urls.url(r'^$', views.index, name='index'), +] diff --git a/tests/test_prefix.py b/tests/test_prefix.py index 43fcbe9..1440f70 100644 --- a/tests/test_prefix.py +++ b/tests/test_prefix.py @@ -12,21 +12,21 @@ def test_prefix(self, mock_client): def get_keys(): return set(sum( - [x[0][1].keys() for x in mock_client._send.call_args_list], + [list(x[0][1]) for x in mock_client._send.call_args_list], [] )) middleware.StatsdMiddleware.start() middleware.StatsdMiddleware.stop() - assert get_keys() == set(( + assert get_keys() >= set(( 'some_key_prefix.view.hit', 'some_key_prefix.view.site.hit', 'some_key_prefix.view.total', )) test.Client().get('/test_app/') - assert get_keys() == set([ + assert get_keys() >= set([ 'some_key_prefix.view.get.tests.test_app.views.index.hit', 'some_key_prefix.view.get.tests.test_app.views.index.' 'process_request', diff --git a/tests/urls.py b/tests/urls.py index c2d1bac..c1b7ebe 100644 --- a/tests/urls.py +++ b/tests/urls.py @@ -1,5 +1,5 @@ -from django.conf.urls import patterns, include, url +from django.conf import urls -urlpatterns = patterns('', - url(r'^test_app/$', include('tests.test_app.urls')), - ) +urlpatterns = [ + urls.url(r'^test_app/$', urls.include('tests.test_app.urls')), +] diff --git a/tox.ini b/tox.ini index ef30767..3c5a6e7 100644 --- a/tox.ini +++ b/tox.ini @@ -1,17 +1,41 @@ [tox] -envlist = py26, py27, pypy, pypy3, py32, py33, py34, py35, flake8, docs +envlist = + py{py,27}-django11, + py35-django{11,20}, + py36-django{11,20}, + flake8, + docs + skip_missing_interpreters = True +usedevelop = True [testenv] -deps = -r{toxinidir}/tests/requirements.txt -commands = {envpython} setup.py test +deps = + django11: Django<2.0 + django20: Django>=2.0,<2.1 + -r{toxinidir}/tests/requirements.txt + +envlist = + py{py,27}-django11, + py35-django{11,20}, + py36-django{11,20}, + +commands = + python setup.py test [testenv:flake8] deps = flake8 -commands = flake8 --ignore=W391 django_statsd tests +commands = flake8 --ignore=W391 django_statsd {posargs} [testenv:docs] +whitelist_externals = + rm + cd + mkdir +commands = + rm -f docs/modules.rst + mkdir -p docs/_static + sphinx-apidoc -o docs/ django_statsd + rm -f docs/modules.rst + sphinx-build -W -b html -d docs/_build/doctrees docs docs/_build/html {posargs} deps = -r{toxinidir}/docs/requirements.txt -basepython = python -commands = sphinx-build -W -b html -d {envtmpdir}/doctrees \ - {toxinidir}/docs {envtmpdir}/html