/usr/lib/python2.7/dist-packages/testfixtures/django.py is in python-testfixtures 4.14.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | from __future__ import absolute_import
from functools import partial
from django.db.models import Model
from django.forms import model_to_dict
from .comparison import _compare_mapping, register
from . import compare as base_compare
def compare_model(x, y, context):
ignore_fields = context.get_option('ignore_fields', set())
args = []
for obj in x, y:
args.append({k: v for (k, v) in model_to_dict(obj).items()
if k not in ignore_fields})
args.append(context)
args.append(x)
return _compare_mapping(*args)
register(Model, compare_model)
compare = partial(base_compare, ignore_eq=True)
|