Skip to content

Commit

Permalink
trying tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoor committed Jan 4, 2016
1 parent 58c1865 commit 6c5c8ed
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion contactbox/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from django.contrib import admin
from django.contrib.admin.util import unquote
from django.contrib.admin.utils import unquote
from models import Message, Receiver


Expand Down
20 changes: 15 additions & 5 deletions contactbox/test_runner.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import sys
import django
coverage = None
try:
from coverage import coverage
Expand All @@ -10,13 +11,22 @@
current_dirname = os.path.dirname(__file__)
sys.path.insert(0, current_dirname)
sys.path.insert(0, os.path.join(current_dirname, '..'))

from django import setup
setup()

print 1
from django.test.runner import DiscoverRunner
from django.db.models import get_app # , get_apps
print 2
# if django.VERSION < (1, 9, 0):
# from django.db.models import get_app
# app = get_app('contactbox')
# print app
# else:
# from django.apps import apps
# app = apps.get_app_config('contactbox').models
# print app
print 3
import fnmatch
print 4

# necessary for "python setup.py test"
patterns = (
Expand Down Expand Up @@ -69,7 +79,6 @@ def get_all_coverage_modules(app_module, exclude_patterns=[]):
class TestSuiteRunner(DiscoverRunner):

def run_tests(self, test_labels=('contactbox',), extra_tests=None):

if coverage:
cov = coverage()
cov.erase()
Expand All @@ -80,7 +89,8 @@ def run_tests(self, test_labels=('contactbox',), extra_tests=None):

if coverage:
cov.stop()
app = get_app('contactbox')
from django.apps import apps
app = apps.get_app_config('contactbox').models
modules = get_all_coverage_modules(app)
cov.html_report(modules, directory='coverage')

Expand Down

0 comments on commit 6c5c8ed

Please sign in to comment.