Skip to content

Commit

Permalink
Merge pull request #47 from brmc/tox
Browse files Browse the repository at this point in the history
Tox integration added
  • Loading branch information
mtford90 committed Dec 30, 2014
2 parents dbfb03d + cd2c95e commit 66516fb
Show file tree
Hide file tree
Showing 47 changed files with 104 additions and 61 deletions.
27 changes: 10 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
language: python
python:
- "2.7"
- "3.3"
- "3.4"
install:
- pip install tox
script:
- tox
env:
- DJANGO_VERSION=1.5
- DJANGO_VERSION=1.6


install:
- pip install -q Django==$DJANGO_VERSION
- pip install -r requirements.txt

script:
- cp -r silk django_silky/silk
- cd django_silky
- ./manage.py test silk

- TOXENV=py27
- TOXENV=py33
- TOXENV=py34
- TOXENV=django15
- TOXENV=django16
- TOXENV=django17
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Documentation is available [here](http://silk.readthedocs.org/en/latest/) and th

Silk has been tested with:

* Django: 1.5, 1.6
* Django: 1.5, 1.6, 1.7
* Python: 2.7, 3.3, 3.4

I left out Django <1.5 due to the change in `{% url %}` syntax. Python 2.6 is missing `collections.Counter`. Python 3.0 and 3.1 are not available via Travis and also are missing the `u'xyz'` syntax for unicode. Workarounds can likely be found for all these if there is any demand. Django 1.7 is currently untested.
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Django>=1.5,
Django==1.6.8
Pygments==1.6
six==1.6.0
simplejson==3.1.2
Expand Down
15 changes: 0 additions & 15 deletions silk/tests/__init__.py

This file was deleted.

15 changes: 15 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from .tests.test_code_gen_curl import *
from .tests.test_collector import *
from .tests.test_dynamic_profiling import *
from .tests.test_execute_sql import *
from .tests.test_silky_middleware import *
from .tests.test_silky_profiler import *
from .tests.test_view_profiling import *
from .tests.test_view_requests import *
from .tests.test_end_points import *
from .tests.test_config_auth import *
from .tests.test_config_max_body_size import *
from .tests.test_config_meta import *
from .tests.test_view_sql_detail import *
from .tests.test_filters import *
from .tests.test_encoding import *
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 3 additions & 1 deletion django_silky/manage.py → tests/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
import os
import sys

sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.path.pardir))

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_silky.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")

from django.core.management import execute_from_command_line

Expand Down
18 changes: 13 additions & 5 deletions django_silky/django_silky/settings.py → tests/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import django

BASE_DIR = os.path.dirname(os.path.dirname(__file__))

Expand All @@ -18,11 +19,20 @@
'django.contrib.contenttypes',
'django.contrib.messages',
'django.contrib.sessions',
# 'south',
'silk',
# Added so tests will pass for django 1.5
#'tests',
'example_app'
)

# A quick hack to get tests to pass for django 1.5
if django.VERSION < (1, 6):
INSTALLED_APPS += ("tests", )
ROOT_URLCONF = 'tests.urls'

else:
ROOT_URLCONF = 'urls'

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
Expand All @@ -33,9 +43,7 @@
'silk.middleware.SilkyMiddleware'
)

ROOT_URLCONF = 'django_silky.urls'

WSGI_APPLICATION = 'django_silky.wsgi.application'
WSGI_APPLICATION = 'wsgi.application'

DB_NAME = os.path.join(BASE_DIR, 'db.sqlite3')

Expand Down Expand Up @@ -98,7 +106,7 @@
os.mkdir(MEDIA_ROOT)

TEMPLATE_DIRS = (
BASE_DIR
BASE_DIR,
)

# A tuple of template loader classes, specified as strings. Each Loader class
Expand Down
1 change: 1 addition & 0 deletions tests/silk
12 changes: 12 additions & 0 deletions tests/test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Pygments==1.6
six==1.6.0
simplejson==3.1.2
python-dateutil==2.2
requests==2.2.1
sqlparse==0.1.11
Jinja2==2.7.2
autopep8==1.0.2
pytz>2014.2
mock==1.0.1
Pillow==2.5.1
South==1.0
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import unittest
import subprocess

from silk.tests.util import PORT, construct_echo_process
from .util import PORT, construct_echo_process



Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from silk.collector import DataCollector
from silk.middleware import SilkyMiddleware

from silk.tests.util import delete_all_models
from .util import delete_all_models
from silk.config import SilkyConfig
from silk.models import Request

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def foo(_):

# noinspection PyUnresolvedReferences
with patch.object(MyClass, 'foo', foo):
profile_function_or_method('silk.tests.test_dynamic_profiling', 'MyClass.foo', 'test')
profile_function_or_method('tests.tests.test_dynamic_profiling', 'MyClass.foo', 'test')
mock_data_collector = Mock()
mock_data_collector.queries = []
mock_data_collector.request = Request()
Expand All @@ -80,7 +80,7 @@ def foo(_):
def test_func_as_str(self):
name = foo.__name__
line_num = six.get_function_code(foo).co_firstlineno
profile_function_or_method('silk.tests.test_dynamic_profiling', 'foo', 'test')
profile_function_or_method('tests.tests.test_dynamic_profiling', 'foo', 'test')
mock_data_collector = Mock()
mock_data_collector.queries = []
mock_data_collector.request = Request()
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from silk import models
from silk.middleware import silky_reverse

from silk.tests import MockSuite
from .test_lib.mock_suite import MockSuite


class TestEndPoints(TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from silk.collector import DataCollector
from silk.models import SQLQuery, Request
from silk.sql import execute_sql
from silk.tests.util import delete_all_models
from .util import delete_all_models


def mock_sql():
Expand Down
3 changes: 2 additions & 1 deletion silk/tests/test_filters.py → tests/tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from silk import models
from silk.request_filters import SecondsFilter, AfterDateFilter, BeforeDateFilter, ViewNameFilter, PathFilter, NameFilter, FunctionNameFilter, NumQueriesFilter, TimeSpentOnQueriesFilter, \
OverallTimeFilter
from silk.tests import MockSuite, delete_all_models
from .test_lib.mock_suite import MockSuite
from .util import delete_all_models


mock_suite = MockSuite()
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ def test_dynamic_decorator(self):
middleware = SilkyMiddleware()
SilkyConfig().SILKY_DYNAMIC_PROFILING = [
{
'module': 'silk.tests.data.dynamic',
'module': 'tests.tests.data.dynamic',
'function': 'foo'
}
]
middleware._apply_dynamic_mappings()
from silk.tests.data.dynamic import foo
from .data.dynamic import foo

mock = Mock()
mock.queries = []
Expand All @@ -30,14 +30,14 @@ def test_dynamic_context_manager(self):
middleware = SilkyMiddleware()
SilkyConfig().SILKY_DYNAMIC_PROFILING = [
{
'module': 'silk.tests.data.dynamic',
'module': 'tests.tests.data.dynamic',
'function': 'foo',
'start_line': 1,
'end_line': 2,
}
]
middleware._apply_dynamic_mappings()
from silk.tests.data.dynamic import foo
from .data.dynamic import foo

mock = Mock()
mock.queries = []
Expand All @@ -50,7 +50,7 @@ def test_invalid_dynamic_context_manager(self):
middleware = SilkyMiddleware()
SilkyConfig().SILKY_DYNAMIC_PROFILING = [
{
'module': 'silk.tests.data.dynamic',
'module': 'tests.tests.data.dynamic',
'function': 'foo2',
'start_line': 1,
'end_line': 7,
Expand All @@ -62,7 +62,7 @@ def test_invalid_dynamic_decorator_module(self):
middleware = SilkyMiddleware()
SilkyConfig().SILKY_DYNAMIC_PROFILING = [
{
'module': 'silk.tests.data.dfsdf',
'module': 'tests.tests.data.dfsdf',
'function': 'foo'
}
]
Expand All @@ -72,7 +72,7 @@ def test_invalid_dynamic_decorator_function_name(self):
middleware = SilkyMiddleware()
SilkyConfig().SILKY_DYNAMIC_PROFILING = [
{
'module': 'silk.tests.data.dynamic',
'module': 'tests.tests.data.dynamic',
'function': 'bar'
}
]
Expand All @@ -82,7 +82,7 @@ def test_invalid_dynamic_mapping(self):
middleware = SilkyMiddleware()
SilkyConfig().SILKY_DYNAMIC_PROFILING = [
{
'dfgdf': 'silk.tests.data.dynamic',
'dfgdf': 'tests.tests.data.dynamic',
'funcgdfgtion': 'bar'
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from silk.models import Request, _time_taken
from silk.profiling.profiler import silk_profile
from silk.tests.test_lib.mock_suite import MockSuite
from .test_lib.mock_suite import MockSuite


class TestProfilerRequests(TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.test import TestCase
from mock import Mock

from silk.tests.test_lib.mock_suite import MockSuite
from .test_lib.mock_suite import MockSuite
from silk.views.profiling import ProfilingView


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.test import TestCase
from mock import Mock

from silk.tests.test_lib.mock_suite import MockSuite
from .test_lib.mock_suite import MockSuite
from silk.views.requests import RequestsView


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from silk.views.sql_detail import SQLDetailView

from silk.tests import MockSuite
from .test_lib.mock_suite import MockSuite


class TestViewSQLDetail(TestCase):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.test import TestCase
from silk.tests import MockSuite
from .test_lib.mock_suite import MockSuite
from silk.views.summary import SummaryView


Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion django_silky/django_silky/wsgi.py → tests/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"""

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_silky.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
26 changes: 26 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[tox]
envlist = django15, django16, django17, py27, py33, py34

[testenv]
commands = {toxinidir}/tests/manage.py test
setenv =
DJANGO_SETTINGS_MODULE=settings
PYTHONPATH={toxinidir}/tests

deps =
-r{toxinidir}/tests/test-requirements.txt

[testenv:django15]
deps =
django==1.5.11
-r{toxinidir}/tests/test-requirements.txt

[testenv:django16]
deps =
django==1.6.8
-r{toxinidir}/tests/test-requirements.txt

[testenv:django17]
deps =
-r{toxinidir}/tests/test-requirements.txt
django>=1.7

0 comments on commit 66516fb

Please sign in to comment.