-
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d066597
commit 3d28203
Showing
17 changed files
with
160 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[run] | ||
branch = True | ||
source = silk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ var/ | |
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
.eggs | ||
|
||
# Installer logs | ||
pip-log.txt | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,48 @@ | ||
language: python | ||
dist: xenial | ||
sudo: false | ||
language: python | ||
cache: pip | ||
python: | ||
- '3.5' | ||
- '3.6' | ||
- '3.7' | ||
- '3.8' | ||
env: | ||
- DJANGO="Django>=2.2,<2.3.0" DB=postgresql DB_NAME=travis_ci_test | ||
- DJANGO="Django>=3.0" DB=postgresql DB_NAME=travis_ci_test | ||
- DJANGO="Django>=2.2,<2.3.0" DB=sqlite3 DB_NAME=db.sqlite3 | ||
- DJANGO="Django>=3.0" DB=sqlite3 DB_NAME=db.sqlite3 | ||
- DJANGO="Django>=2.2,<2.3.0" DB=mysql DB_NAME=mysql_db | ||
- DJANGO="Django>=3.0" DB=mysql DB_NAME=mysql_db | ||
matrix: | ||
exclude: | ||
- python: '3.5' | ||
env: DJANGO="Django>=3.0" DB=postgresql DB_NAME=travis_ci_test | ||
- python: '3.5' | ||
env: DJANGO="Django>=3.0" DB=sqlite3 DB_NAME=db.sqlite3 | ||
- python: '3.5' | ||
env: DJANGO="Django>=3.0" DB=mysql DB_NAME=mysql_db | ||
fast_finish: true | ||
- 3.5 | ||
- 3.6 | ||
- 3.7 | ||
- 3.8 | ||
services: | ||
- mysql | ||
- postgresql | ||
install: | ||
- travis_retry pip install -q $DJANGO | ||
- travis_retry pip install -r requirements.txt | ||
- travis_retry pip install -r project/test-requirements.txt | ||
- if [[ "$DB" = "postgresql" ]]; then pip install psycopg2; fi | ||
- if [[ "$DB" = "postgresql" ]]; then psql -c 'create database travis_ci_test;' -U | ||
postgres; fi | ||
- if [[ "$DB" = "mysql" ]]; then pip install mysqlclient; fi | ||
- if [[ "$DB" = "mysql" ]]; then mysql -e 'create database mysql_db;'; fi | ||
script: | ||
- "./project/run_tests.sh" | ||
deploy: | ||
provider: pypi | ||
user: jazzband | ||
server: https://jazzband.co/projects/django-silk/upload | ||
password: | ||
secure: VqpIq4gsetWZFDG7XV72Tg+7zx0zRLcLXlLKM6XVN5LqARx4MVgNWD/lJvf5EWqvXPqcx6DAQN5c5nd35swWjET2XnAR0HO5Bc8F1U/gaHOlvdZBuOSb0PIzl1uPl4JHtwiRJckZELB/O8M8RgJzulZd+28TL37dsH+0baFZ05c= | ||
distributions: sdist bdist_wheel | ||
on: | ||
tags: true | ||
repo: jazzband/django-silk | ||
- pip install tox-travis codecov | ||
- if [[ "$DB" = "mysql" ]]; then mysql -e "create database mysql_db;"; fi | ||
- if [[ "$DB" = "postgresql" ]]; then psql -c "create database travis_ci_test;" -U postgres; fi | ||
script: tox | ||
after_success: codecov | ||
env: | ||
- DJANGO=2.2 DATABASE=sqlite3 | ||
- DJANGO=2.2 DATABASE=mysql | ||
- DJANGO=2.2 DATABASE=postgresql | ||
- DJANGO=3.0 DATABASE=sqlite3 | ||
- DJANGO=3.0 DATABASE=mysql | ||
- DJANGO=3.0 DATABASE=postgresql | ||
jobs: | ||
exclude: | ||
- python: 3.5 | ||
env: DJANGO=3.0 DATABASE=sqlite3 | ||
- python: 3.5 | ||
env: DJANGO=3.0 DATABASE=mysql | ||
- python: 3.5 | ||
env: DJANGO=3.0 DATABASE=postgresql | ||
include: | ||
- stage: deploy | ||
env: | ||
python: 3.6 | ||
script: skip | ||
deploy: | ||
provider: pypi | ||
user: jazzband | ||
server: https://jazzband.co/projects/django-silk/upload | ||
distributions: sdist bdist_wheel | ||
password: | ||
secure: VqpIq4gsetWZFDG7XV72Tg+7zx0zRLcLXlLKM6XVN5LqARx4MVgNWD/lJvf5EWqvXPqcx6DAQN5c5nd35swWjET2XnAR0HO5Bc8F1U/gaHOlvdZBuOSb0PIzl1uPl4JHtwiRJckZELB/O8M8RgJzulZd+28TL37dsH+0baFZ05c= | ||
skip_existing: true | ||
on: | ||
tags: true | ||
repo: jazzband/django-silk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
Pygments>=2.0,<2.1 | ||
pygments>=2.0,<2.1 | ||
simplejson==3.13.2 | ||
python-dateutil>=2.4,<2.5 | ||
requests==2.21.0 | ||
sqlparse==0.2.4 | ||
Jinja2==2.10 | ||
jinja2==2.10 | ||
autopep8==1.4.3 | ||
pytz>2014.2 | ||
mock==2.0.0 | ||
Pillow==5.4.1 | ||
pillow==5.4.1 | ||
factory-boy==2.9.2 | ||
freezegun==0.3.12 | ||
networkx==1.11 | ||
pydotplus==2.0.2 | ||
contextlib2==0.5.5 | ||
coverage==5.0.3 | ||
pytest-django==3.8.0 | ||
pytest-cov==2.8.1 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,45 @@ | ||
# future | ||
from __future__ import print_function | ||
# std | ||
import cProfile | ||
from io import StringIO | ||
# 3rd party | ||
import io | ||
import re | ||
|
||
import contextlib2 as contextlib | ||
|
||
from django.test import TestCase | ||
# silk | ||
|
||
from silk.utils.profile_parser import parse_profile | ||
|
||
|
||
class ProfileParserTestCase(TestCase): | ||
|
||
def test_profile_parser(self): | ||
""" | ||
Verify that the function parse_profile produces the expected output. | ||
""" | ||
with contextlib.closing(StringIO()) as stream: | ||
with contextlib.closing(io.StringIO()) as stream: | ||
with contextlib.redirect_stdout(stream): | ||
cProfile.run('print()') | ||
stream.seek(0) | ||
actual = list(parse_profile(stream)) | ||
expected = [ | ||
['ncalls', 'tottime', 'percall', 'cumtime', 'percall', 'filename:lineno(function)'], | ||
['1', '0.000', '0.000', '0.000', '0.000', '<string>:1(<module>)'], | ||
['1', '0.000', '0.000', '0.000', '0.000', '{built-in method builtins.exec}'], | ||
['1', '0.000', '0.000', '0.000', '0.000', '{built-in method builtins.print}'], | ||
['1', '0.000', '0.000', '0.000', '0.000', "{method 'disable' of '_lsprof.Profiler' objects}"] | ||
] | ||
self.assertListEqual(actual, expected) | ||
|
||
# Expected format for the profiling output on cPython implementations (PyPy differs) | ||
# actual = [ | ||
# ["ncalls", "tottime", "percall", "cumtime", "percall", "filename:lineno(function)"], | ||
# ["1", "0.000", "0.000", "0.000", "0.000", "<string>:1(<module>)"], | ||
# ["1", "0.000", "0.000", "0.000", "0.000", "{built-in method builtins.exec}"], | ||
# ["1", "0.000", "0.000", "0.000", "0.000", "{built-in method builtins.print}"], | ||
# ["1", "0.000", "0.000", "0.000", "0.000", "{method 'disable' of '_lsprof.Profiler' objects}"], | ||
# ] | ||
|
||
exc_header = ["ncalls", "tottime", "percall", "cumtime", "percall", "filename:lineno(function)"] | ||
self.assertEqual(actual[0], exc_header) | ||
|
||
exc_number = re.compile(r"\d(.\d+)?") | ||
exc_module = re.compile(r"({method.*})|({built-in.*})|(<.+>:\d+\(<.+>\))") | ||
|
||
exc_row = [exc_number, exc_number, exc_number, exc_number, exc_number, exc_module] | ||
|
||
for row in actual[1:]: | ||
for text, expected_regex in zip(row, exc_row): | ||
self.assertRegex( | ||
text, expected_regex, | ||
msg="Expected something like {} but found {}" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[pytest] | ||
addopts = --cov silk --cov-config .coveragerc --cov-append --cov-report term | ||
python_files = test.py tests.py test_*.py tests_*.py *_tests.py *_test.py | ||
DJANGO_SETTINGS_MODULE = project.settings |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.