Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:saxix/django-adminactions into d…
Browse files Browse the repository at this point in the history
…evelop

* 'develop' of github.com:saxix/django-adminactions:
  turn off some warnings about deprecated assertEquals
  run codecov as recommended by them
  pytest-cov already include coverage
  Keep only codecov
  Update trove classifier
  django 1.7 is not maintained anymore longer
  • Loading branch information
saxix committed Nov 18, 2016
2 parents a0a7694 + 0a77b8c commit e50e74d
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 143 deletions.
14 changes: 5 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,22 @@ cache:
- $HOME/.cache/pip

env:
- TOXENV=py27-d17
- TOXENV=py27-d18
- TOXENV=py27-d19
- TOXENV=py27-d110
- TOXENV=py27-ddev

- TOXENV=py33-d17
- TOXENV=py33-d18
- TOXENV=py33-ddev

- TOXENV=py34-d17
- TOXENV=py34-d18
- TOXENV=py34-d19
- TOXENV=py34-ddev

- TOXENV=py35-d18
- TOXENV=py35-d19
- TOXENV=py35-d110
- TOXENV=py35-ddev

- TOXENV=pypy-d17
- TOXENV=pypy-d18
- TOXENV=pypy-d19
- TOXENV=pypy-d110
Expand All @@ -40,18 +37,17 @@ matrix:


install:
- pip install tox "coverage<4.0" python-coveralls>=2.5 coveralls>=0.5 codecov
- pip install -e ".[test]"

script:
- tox -e $TOXENV -- py.test tests -vv --capture=no --cov=adminactions --cov-report=xml --cov-config=tests/.coveragerc
- tox -e $TOXENV -- py.test tests -vv --capture=no --cov=adminactions --cov-report= --cov-config=tests/.coveragerc

before_success:
- coverage erase

after_success:
- coverage combine
- coveralls
- codecov
- bash <(curl -s https://codecov.io/bash)

notifications:
webhooks:
Expand Down
6 changes: 2 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,13 @@ def fread(fname):
'Environment :: Web Environment',
'Framework :: Django',
'Operating System :: OS Independent',
'Framework :: Django :: 1.4',
'Framework :: Django :: 1.5',
'Framework :: Django :: 1.6',
'Framework :: Django :: 1.7',
'Framework :: Django :: 1.8',
'Framework :: Django :: 1.9',
'Framework :: Django :: 1.10',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Intended Audience :: Developers'],
long_description=open('README.rst').read()
)
10 changes: 2 additions & 8 deletions src/adminactions/byrows_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
from .forms import GenericActionForm
from .models import get_permission_codename

if django.VERSION[:2] > (1, 7):
from django.forms.models import modelformset_factory
else:
from django.forms import modelformset_factory
from django.forms.models import modelformset_factory


def byrows_update(modeladmin, request, queryset): # noqa
Expand Down Expand Up @@ -84,10 +81,7 @@ def __init__(self, *args, **kwargs):
'opts': modeladmin.model._meta,
'app_label': modeladmin.model._meta.app_label,
}
if django.VERSION[:2] > (1, 7):
ctx.update(modeladmin.admin_site.each_context(request))
else:
ctx.update(modeladmin.admin_site.each_context())
ctx.update(modeladmin.admin_site.each_context(request))

return render_to_response(tpl, RequestContext(request, ctx))

Expand Down
59 changes: 7 additions & 52 deletions src/adminactions/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,14 @@

version = django.VERSION[:2]

if version <= (1, 5): # noqa
from django.db.transaction import atomic # noqa

@contextmanager
def nocommit(using=None):
t.enter_transaction_management(using=using)
t.managed(True, using=using)
yield
t.rollback()
t.leave_transaction_management(using=using)
class NoCommit(t.Atomic):
def __exit__(self, exc_type, exc_value, traceback):
super(NoCommit, self).__exit__(Exception, Exception(), None)

class atomic(object):
def __init__(self, using=None):
self.using = using

def __enter__(self):
t.enter_transaction_management(using=self.using)
t.managed(True, using=self.using)

def __exit__(self, exc_type, exc_value, traceback):
try:
if exc_type is not None:
if t.is_dirty(using=self.using):
t.rollback(using=self.using)
else:
if t.is_dirty(using=self.using):
try:
t.commit(using=self.using)
except:
t.rollback(using=self.using)
raise
finally:
t.leave_transaction_management(using=self.using)


else:
from django.db.transaction import atomic # noqa

class NoCommit(t.Atomic):
def __exit__(self, exc_type, exc_value, traceback):
super(NoCommit, self).__exit__(Exception, Exception(), None)

def nocommit(using=None, savepoint=True):
return NoCommit(using, savepoint)
def nocommit(using=None, savepoint=True):
return NoCommit(using, savepoint)


# Model._meta compatibility
Expand All @@ -74,17 +39,7 @@ def get_all_field_names(model):
# For complete backwards compatibility, you may want to exclude
# GenericForeignKey from the results.
if not (field.many_to_one and field.related_model is None))))
# elif version >= (1, 9): # noqa
# pass
# elif version >= (1, 8): # noqa
# pass
# elif version >= (1, 7): # noqa
# pass
# elif version >= (1, 6): # noqa
# pass
# elif version >= (1, 5): # noqa
# pass
elif version >= (1, 4): # noqa
else:
def get_all_related_objects(model):
return model._meta.get_all_related_objects()

Expand Down
15 changes: 3 additions & 12 deletions src/adminactions/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,7 @@ def base_export(modeladmin, request, queryset, title, impl, # noqa
'opts': queryset.model._meta,
'app_label': queryset.model._meta.app_label,
'media': mark_safe(media)}
if django.VERSION[:2] > (1, 7):
ctx.update(modeladmin.admin_site.each_context(request))
else:
ctx.update(modeladmin.admin_site.each_context())
ctx.update(modeladmin.admin_site.each_context(request))
return render_to_response(template, RequestContext(request, ctx))


Expand Down Expand Up @@ -316,10 +313,7 @@ def export_as_fixture(modeladmin, request, queryset):
'opts': queryset.model._meta,
'app_label': queryset.model._meta.app_label,
'media': mark_safe(media)}
if django.VERSION[:2] > (1, 7):
ctx.update(modeladmin.admin_site.each_context(request))
else:
ctx.update(modeladmin.admin_site.each_context())
ctx.update(modeladmin.admin_site.each_context(request))
return render_to_response(tpl, RequestContext(request, ctx))


Expand Down Expand Up @@ -411,10 +405,7 @@ def export_delete_tree(modeladmin, request, queryset): # noqa
'opts': queryset.model._meta,
'app_label': queryset.model._meta.app_label,
'media': mark_safe(media)}
if django.VERSION[:2] > (1, 7):
ctx.update(modeladmin.admin_site.each_context(request))
else:
ctx.update(modeladmin.admin_site.each_context())
ctx.update(modeladmin.admin_site.each_context(request))
return render_to_response(tpl, RequestContext(request, ctx))


Expand Down
5 changes: 1 addition & 4 deletions src/adminactions/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,7 @@ def graph_queryset(modeladmin, request, queryset): # noqa
'extra': extra,
'as_json': json.dumps(table),
'graph_type': graph_type}
if django.VERSION[:2] > (1, 7):
ctx.update(modeladmin.admin_site.each_context(request))
else:
ctx.update(modeladmin.admin_site.each_context())
ctx.update(modeladmin.admin_site.each_context(request))
return render_to_response('adminactions/charts.html', RequestContext(request, ctx))


Expand Down
5 changes: 1 addition & 4 deletions src/adminactions/mass_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,7 @@ def _doit():
# 'select_across': request.POST.get('select_across')=='1',
'media': mark_safe(media),
'selection': queryset}
if django.VERSION[:2] > (1, 7):
ctx.update(modeladmin.admin_site.each_context(request))
else:
ctx.update(modeladmin.admin_site.each_context())
ctx.update(modeladmin.admin_site.each_context(request))

if django.VERSION[:2] > (1, 8):
return render(request, tpl, context=ctx)
Expand Down
5 changes: 1 addition & 4 deletions src/adminactions/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,7 @@ def raw_widget(field, **kwargs):
),
'master': master,
'other': other})
if django.VERSION[:2] > (1, 7):
ctx.update(modeladmin.admin_site.each_context(request))
else:
ctx.update(modeladmin.admin_site.each_context())
ctx.update(modeladmin.admin_site.each_context(request))
if django.VERSION[:2] > (1, 8):
return render(request, tpl, context=ctx)
else:
Expand Down
1 change: 0 additions & 1 deletion src/requirements/testing.pip
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
coverage
check-manifest
django-dynamic-fixture
django-webtest>=1.7.5
Expand Down
30 changes: 15 additions & 15 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_default_params(self):
qs = Permission.objects.select_related().filter(codename='add_user')
ret = export_as_csv(queryset=qs)
self.assertIsInstance(ret, HttpResponse)
self.assertEquals(ret.content.decode('utf8'), u'"%s";"Can add user";"user";"add_user"\r\n' % qs[0].pk)
self.assertEqual(ret.content.decode('utf8'), u'"%s";"Can add user";"user";"add_user"\r\n' % qs[0].pk)

def test_header_is_true(self):
mem = six.StringIO()
Expand All @@ -45,9 +45,9 @@ def test_queryset_values(self):
mem.seek(0)
csv_dump = mem.read()
if six.PY2:
self.assertEquals(csv_dump.decode('utf8'), u'"Name";"Application"\r\n"add_user";"auth"\r\n')
self.assertEqual(csv_dump.decode('utf8'), u'"Name";"Application"\r\n"add_user";"auth"\r\n')
else:
self.assertEquals(csv_dump, '"Name";"Application"\r\n"add_user";"auth"\r\n')
self.assertEqual(csv_dump, '"Name";"Application"\r\n"add_user";"auth"\r\n')

def test_callable_method(self):
fields = ['codename', 'natural_key']
Expand All @@ -58,9 +58,9 @@ def test_callable_method(self):
mem.seek(0)
csv_dump = mem.read()
if six.PY2:
self.assertEquals(csv_dump.decode('utf8'), u'"add_user";"(u\'add_user\', u\'auth\', u\'user\')"\r\n')
self.assertEqual(csv_dump.decode('utf8'), u'"add_user";"(u\'add_user\', u\'auth\', u\'user\')"\r\n')
else:
self.assertEquals(csv_dump, '"add_user";"(\'add_user\', \'auth\', \'user\')"\r\n')
self.assertEqual(csv_dump, '"add_user";"(\'add_user\', \'auth\', \'user\')"\r\n')

def test_deep_attr(self):
fields = ['codename', 'content_type.app_label']
Expand All @@ -71,9 +71,9 @@ def test_deep_attr(self):
mem.seek(0)
csv_dump = mem.read()
if six.PY2:
self.assertEquals(csv_dump.decode('utf8'), u'"add_user";"auth"\r\n')
self.assertEqual(csv_dump.decode('utf8'), u'"add_user";"auth"\r\n')
else:
self.assertEquals(csv_dump, '"add_user";"auth"\r\n')
self.assertEqual(csv_dump, '"add_user";"auth"\r\n')


class TestExportAsCsv(unittest.TestCase):
Expand All @@ -89,9 +89,9 @@ def test_export_as_csv(self):
mem.seek(0)
csv_dump = mem.read()
if six.PY2:
self.assertEquals(csv_dump.decode('utf8'), u'"Field 1";"Field 2"\r\n"1";"4"\r\n"2";"5"\r\n"3";"ӼӳӬԖԊ"\r\n')
self.assertEqual(csv_dump.decode('utf8'), u'"Field 1";"Field 2"\r\n"1";"4"\r\n"2";"5"\r\n"3";"ӼӳӬԖԊ"\r\n')
else:
self.assertEquals(csv_dump, '"Field 1";"Field 2"\r\n"1";"4"\r\n"2";"5"\r\n"3";"ӼӳӬԖԊ"\r\n')
self.assertEqual(csv_dump, '"Field 1";"Field 2"\r\n"1";"4"\r\n"2";"5"\r\n"3";"ӼӳӬԖԊ"\r\n')

def test_dialect(self):
fields = ['field1', 'field2']
Expand All @@ -106,9 +106,9 @@ def test_dialect(self):
mem.seek(0)
csv_dump = mem.read()
if six.PY2:
self.assertEquals(csv_dump.decode('utf8'), u'Field 1,Field 2\r\n1,4\r\n2,5\r\n3,ӼӳӬԖԊ\r\n')
self.assertEqual(csv_dump.decode('utf8'), u'Field 1,Field 2\r\n1,4\r\n2,5\r\n3,ӼӳӬԖԊ\r\n')
else:
self.assertEquals(csv_dump, 'Field 1,Field 2\r\n1,4\r\n2,5\r\n3,ӼӳӬԖԊ\r\n')
self.assertEqual(csv_dump, 'Field 1,Field 2\r\n1,4\r\n2,5\r\n3,ӼӳӬԖԊ\r\n')


class TestExportAsExcel(TestCase):
Expand Down Expand Up @@ -163,8 +163,8 @@ def test_queryset_values(self):
mem.seek(0)
w = xlrd.open_workbook(file_contents=mem.read())
sheet = w.sheet_by_index(0)
self.assertEquals(sheet.cell_value(1, 1), u'add_user')
self.assertEquals(sheet.cell_value(1, 2), u'auth')
self.assertEqual(sheet.cell_value(1, 1), u'add_user')
self.assertEqual(sheet.cell_value(1, 2), u'auth')

def test_callable_method(self):
fields = ['codename', 'natural_key']
Expand All @@ -175,5 +175,5 @@ def test_callable_method(self):
content = mem.read()
w = xlrd.open_workbook(file_contents=content)
sheet = w.sheet_by_index(0)
self.assertEquals(sheet.cell_value(1, 1), u'add_user')
self.assertEquals(sheet.cell_value(1, 2), u'add_userauthuser')
self.assertEqual(sheet.cell_value(1, 1), u'add_user')
self.assertEqual(sheet.cell_value(1, 2), u'add_userauthuser')
2 changes: 1 addition & 1 deletion tests/test_byrows_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ def test_form_rows_edit(self):
res.form.submit('apply')
obj = DemoModel.objects.get(id=self._selected_values[row_to_modify])
for k, v in new_values.items():
self.assertEquals(v, getattr(obj, k))
self.assertEqual(v, getattr(obj, k))

0 comments on commit e50e74d

Please sign in to comment.