File: func_noerror_protected_meta_access.py

package info (click to toggle)
pylint-django 2.0.13-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 660 kB
  • sloc: python: 1,807; sh: 13; makefile: 5
file content (24 lines) | stat: -rw-r--r-- 690 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""
Tests to make sure that access to _meta on a model does not raise
a protected-access warning, as it is part of the public API since
Django 1.8
(see https://github.com/PyCQA/pylint-django/issues/66,
and https://docs.djangoproject.com/en/1.9/ref/models/meta/)
"""
#  pylint: disable=missing-docstring
from __future__ import print_function
from django.db import models


class ModelWhichLikesMeta(models.Model):
    ursuary = models.BooleanField(default=False)

    def do_a_thing(self):
        return self._meta.get_field('ursuary')


if __name__ == '__main__':
    MODEL = ModelWhichLikesMeta()
    MODEL.save()
    print(MODEL._meta.get_field('ursuary'))
    print(MODEL.do_a_thing())