id int64 0 458k | file_name stringlengths 4 119 | file_path stringlengths 14 227 | content stringlengths 24 9.96M | size int64 24 9.96M | language stringclasses 1
value | extension stringclasses 14
values | total_lines int64 1 219k | avg_line_length float64 2.52 4.63M | max_line_length int64 5 9.91M | alphanum_fraction float64 0 1 | repo_name stringlengths 7 101 | repo_stars int64 100 139k | repo_forks int64 0 26.4k | repo_open_issues int64 0 2.27k | repo_license stringclasses 12
values | repo_extraction_date stringclasses 433
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3,200 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/datatypes/models.py | """
This is a basic model to test saving and loading boolean and date-related
types, which in the past were problematic for some database backends.
"""
from django.db import models
class Donut(models.Model):
name = models.CharField(max_length=100)
is_frosted = models.BooleanField(default=False)
has_sprink... | 771 | Python | .py | 20 | 34.3 | 73 | 0.733244 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,201 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/datatypes/tests.py | import datetime
from django.db import DEFAULT_DB_ALIAS
from django.test import TestCase
from django.utils import tzinfo
from models import Donut, RumBaba
from django.conf import settings
class DataTypesTestCase(TestCase):
def test_boolean_type(self):
d = Donut(name='Apple Fritter')
self.assertFal... | 4,274 | Python | .py | 75 | 47.853333 | 113 | 0.665869 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,202 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/defaultfilters/tests.py | # -*- coding: utf-8 -*-
import datetime
import unittest
from django.template.defaultfilters import *
class DefaultFiltersTests(unittest.TestCase):
def test_floatformat(self):
self.assertEqual(floatformat(7.7), u'7.7')
self.assertEqual(floatformat(7.0), u'7')
self.assertEqual(floatformat(0... | 23,204 | Python | .py | 426 | 43.046948 | 87 | 0.576289 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,203 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/model_regress/models.py | # coding: utf-8
from django.db import models
CHOICES = (
(1, 'first'),
(2, 'second'),
)
class Article(models.Model):
headline = models.CharField(max_length=100, default='Default headline')
pub_date = models.DateTimeField()
status = models.IntegerField(blank=True, null=True, choices=CHOICES)
m... | 1,683 | Python | .py | 44 | 33.113636 | 76 | 0.701419 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,204 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/model_regress/tests.py | import datetime
from operator import attrgetter
from django.conf import settings
from django.core.exceptions import ValidationError
from django.db import DEFAULT_DB_ALIAS
from django.test import TestCase
from django.utils import tzinfo
from models import (Worker, Article, Party, Event, Department,
BrokenUnicodeMe... | 6,781 | Python | .py | 158 | 33.025316 | 88 | 0.610808 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,205 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/cache/models.py | from django.db import models
from datetime import datetime
def expensive_calculation():
expensive_calculation.num_runs += 1
return datetime.now()
class Poll(models.Model):
question = models.CharField(max_length=200)
answer = models.CharField(max_length=200)
pub_date = models.DateTimeField('date pu... | 361 | Python | .py | 9 | 36.666667 | 84 | 0.777143 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,206 | urls.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/cache/urls.py | from django.conf.urls.defaults import patterns
urlpatterns = patterns('regressiontests.cache.views',
(r'^$', 'home'),
)
| 125 | Python | .py | 4 | 29 | 53 | 0.741667 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,207 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/cache/tests.py | # -*- coding: utf-8 -*-
# Unit tests for cache framework
# Uses whatever cache backend is set in the test settings file.
import os
import tempfile
import time
import unittest
import warnings
from django.conf import settings
from django.core import management
from django.core.cache import get_cache
from django.core.c... | 28,208 | Python | .py | 579 | 40.025907 | 186 | 0.647339 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,208 | liberal_backend.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/cache/liberal_backend.py | from django.core.cache.backends.locmem import CacheClass as LocMemCacheClass
class LiberalKeyValidationMixin(object):
def validate_key(self, key):
pass
class CacheClass(LiberalKeyValidationMixin, LocMemCacheClass):
pass
| 239 | Python | .py | 6 | 35.666667 | 76 | 0.817391 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,209 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/requests/tests.py | from datetime import datetime, timedelta
import time
import unittest
from django.http import HttpRequest, HttpResponse, parse_cookie
from django.core.handlers.wsgi import WSGIRequest
from django.core.handlers.modpython import ModPythonRequest
from django.utils.http import cookie_date
class RequestsTests(unittest.Test... | 2,389 | Python | .py | 49 | 40.510204 | 103 | 0.654506 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,210 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/many_to_one_regress/models.py | """
Regression tests for a few ForeignKey bugs.
"""
from django.db import models
# If ticket #1578 ever slips back in, these models will not be able to be
# created (the field names being lower-cased versions of their opposite
# classes is important here).
class First(models.Model):
second = models.IntegerField(... | 1,396 | Python | .py | 33 | 38.727273 | 80 | 0.732593 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,211 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/many_to_one_regress/tests.py | from django.db import models
from django.test import TestCase
from models import First, Second, Third, Parent, Child, Category, Record, Relation
class ManyToOneRegressionTests(TestCase):
def test_object_creation(self):
Third.objects.create(id='3', name='An example')
parent = Parent(name='fred')
... | 4,466 | Python | .py | 83 | 45.120482 | 110 | 0.665902 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,212 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/text/tests.py | # coding: utf-8
from django.test import TestCase
from django.utils.text import *
from django.utils.http import urlquote, urlquote_plus, cookie_date, http_date
from django.utils.encoding import iri_to_uri
class TextTests(TestCase):
"""
Tests for stuff in django.utils.text and other text munging util functions.... | 3,179 | Python | .py | 58 | 45.551724 | 93 | 0.615881 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,213 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/app_loading/tests.py | import copy
import os
import sys
import time
from unittest import TestCase
from django.conf import Settings
from django.db.models.loading import cache, load_app
class InstalledAppsGlobbingTest(TestCase):
def setUp(self):
self.OLD_SYS_PATH = sys.path[:]
sys.path.append(os.path.dirname(os.path.absp... | 3,007 | Python | .py | 68 | 36.294118 | 104 | 0.642955 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,214 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/generic_relations_regress/models.py | from django.db import models
from django.contrib.contenttypes import generic
from django.contrib.contenttypes.models import ContentType
__all__ = ('Link', 'Place', 'Restaurant', 'Person', 'Address',
'CharLink', 'TextLink', 'OddRelation1', 'OddRelation2',
'Contact', 'Organization', 'Note')
clas... | 2,612 | Python | .py | 61 | 38.04918 | 82 | 0.727596 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,215 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/generic_relations_regress/tests.py | from django.test import TestCase
from django.contrib.contenttypes.models import ContentType
from django.db.models import Q
from models import *
class GenericRelationTests(TestCase):
def test_inherited_models_content_type(self):
"""
Test that GenericRelations on inherited classes use the correct co... | 2,909 | Python | .py | 60 | 38.883333 | 79 | 0.647972 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,216 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/httpwrappers/tests.py | import copy
import pickle
import unittest
from django.http import QueryDict, HttpResponse, CompatCookie, BadHeaderError
class QueryDictTests(unittest.TestCase):
def test_missing_key(self):
q = QueryDict('')
self.assertRaises(KeyError, q.__getitem__, 'foo')
def test_immutability(self):
... | 10,760 | Python | .py | 223 | 39.560538 | 99 | 0.602439 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,217 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/i18n/models.py | from datetime import datetime
from django.db import models
from django.utils.translation import ugettext_lazy as _
class TestModel(models.Model):
text = models.CharField(max_length=10, default=_('Anything'))
class Company(models.Model):
name = models.CharField(max_length=50)
date_added = models.DateTimeFi... | 481 | Python | .py | 10 | 44.9 | 77 | 0.773987 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,218 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/i18n/tests.py | # -*- encoding: utf-8 -*-
import datetime
import decimal
import os
import sys
import pickle
from django.conf import settings
from django.template import Template, Context
from django.test import TestCase
from django.utils.formats import (get_format, date_format, time_format,
localize, localize_input, iter_format_m... | 42,903 | Python | .py | 712 | 50.061798 | 2,017 | 0.620959 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,219 | forms.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/i18n/forms.py | from django import template, forms
from django.forms.extras import SelectDateWidget
from models import Company
class I18nForm(forms.Form):
decimal_field = forms.DecimalField(localize=True)
float_field = forms.FloatField(localize=True)
date_field = forms.DateField(localize=True)
datetime_field = forms.D... | 816 | Python | .py | 18 | 41.222222 | 83 | 0.782116 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,220 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/model_inheritance_regress/models.py | import datetime
from django.db import models
class Place(models.Model):
name = models.CharField(max_length=50)
address = models.CharField(max_length=80)
class Meta:
ordering = ('name',)
def __unicode__(self):
return u"%s the place" % self.name
class Restaurant(Place):
serves_hot... | 3,932 | Python | .py | 105 | 32.419048 | 76 | 0.71723 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,221 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/model_inheritance_regress/tests.py | """
Regression tests for Model inheritance behaviour.
"""
import datetime
from operator import attrgetter
from django.test import TestCase
from models import (Place, Restaurant, ItalianRestaurant, ParkingLot,
ParkingLot2, ParkingLot3, Supplier, Wholesaler, Child, SelfRefParent,
SelfRefChild, ArticleWithAutho... | 14,481 | Python | .py | 336 | 33.28869 | 78 | 0.620663 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,222 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/signals_regress/models.py | from django.db import models
class Author(models.Model):
name = models.CharField(max_length=20)
def __unicode__(self):
return self.name
class Book(models.Model):
name = models.CharField(max_length=20)
authors = models.ManyToManyField(Author)
def __unicode__(self):
return self.nam... | 322 | Python | .py | 10 | 27.2 | 44 | 0.701299 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,223 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/signals_regress/tests.py | import sys
from StringIO import StringIO
from django.test import TestCase
from django.db import models
from regressiontests.signals_regress.models import Author, Book
signal_output = []
def pre_save_test(signal, sender, instance, **kwargs):
signal_output.append('pre_save signal, %s' % instance)
if kwargs.get... | 3,760 | Python | .py | 79 | 38.772152 | 83 | 0.649836 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,224 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/admin_scripts/models.py | from django.db import models
class Article(models.Model):
headline = models.CharField(max_length=100, default='Default headline')
pub_date = models.DateTimeField()
def __unicode__(self):
return self.headline
class Meta:
ordering = ('-pub_date', 'headline')
| 300 | Python | .py | 8 | 31.125 | 75 | 0.690391 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,225 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/admin_scripts/tests.py | """
A series of tests to establish that the command-line managment tools work as
advertised - especially with regards to the handling of the DJANGO_SETTINGS_MODULE
and default settings.py files.
"""
import os
import unittest
import shutil
import sys
import re
from django import conf, bin, get_version
from django.conf ... | 57,182 | Python | .py | 1,011 | 48.283877 | 241 | 0.667363 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,226 | app_command.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/admin_scripts/management/commands/app_command.py | from django.core.management.base import AppCommand
class Command(AppCommand):
help = 'Test Application-based commands'
requires_model_validation = False
args = '[appname ...]'
def handle_app(self, app, **options):
print 'EXECUTE:AppCommand app=%s, options=%s' % (app, sorted(options.items()))
... | 328 | Python | .py | 7 | 40.857143 | 86 | 0.703226 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,227 | noargs_command.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/admin_scripts/management/commands/noargs_command.py | from django.core.management.base import NoArgsCommand
class Command(NoArgsCommand):
help = "Test No-args commands"
requires_model_validation = False
def handle_noargs(self, **options):
print 'EXECUTE:NoArgsCommand options=%s' % sorted(options.items())
| 275 | Python | .py | 6 | 41 | 74 | 0.74812 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,228 | label_command.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/admin_scripts/management/commands/label_command.py | from django.core.management.base import LabelCommand
class Command(LabelCommand):
help = "Test Label-based commands"
requires_model_validation = False
args = '<label>'
def handle_label(self, label, **options):
print 'EXECUTE:LabelCommand label=%s, options=%s' % (label, sorted(options.items()))... | 321 | Python | .py | 7 | 41.142857 | 92 | 0.717949 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,229 | base_command.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/admin_scripts/management/commands/base_command.py | from django.core.management.base import BaseCommand
from optparse import make_option
class Command(BaseCommand):
option_list = BaseCommand.option_list + (
make_option('--option_a','-a', action='store', dest='option_a', default='1'),
make_option('--option_b','-b', action='store', dest='option_b', de... | 658 | Python | .py | 13 | 45.153846 | 93 | 0.650078 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,230 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/admin_scripts/app_with_import/models.py | from django.contrib.comments.models import Comment
from django.db import models
# Regression for #13368. This is an example of a model
# that imports a class that has an abstract base class.
class CommentScore(models.Model):
comment = models.OneToOneField(Comment, primary_key=True)
| 288 | Python | .py | 6 | 46.166667 | 61 | 0.807829 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,231 | bar.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/admin_scripts/complex_app/models/bar.py | from django.db import models
from admin_scripts.complex_app.admin import foo
class Bar(models.Model):
name = models.CharField(max_length=5)
class Meta:
app_label = 'complex_app'
| 195 | Python | .py | 6 | 28.666667 | 47 | 0.739362 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,232 | __init__.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/admin_scripts/complex_app/models/__init__.py | from admin_scripts.complex_app.models.bar import Bar
from admin_scripts.complex_app.models.foo import Foo
__all__ = ['Foo', 'Bar']
| 132 | Python | .py | 3 | 42.666667 | 52 | 0.757813 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,233 | foo.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/admin_scripts/complex_app/models/foo.py | from django.db import models
class Foo(models.Model):
name = models.CharField(max_length=5)
class Meta:
app_label = 'complex_app'
| 147 | Python | .py | 5 | 25 | 41 | 0.702128 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,234 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/max_lengths/models.py | from django.db import models
class PersonWithDefaultMaxLengths(models.Model):
email = models.EmailField()
vcard = models.FileField(upload_to='/tmp')
homepage = models.URLField()
avatar = models.FilePathField()
class PersonWithCustomMaxLengths(models.Model):
email = models.EmailField(max_length=250... | 482 | Python | .py | 11 | 39.727273 | 62 | 0.75693 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,235 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/max_lengths/tests.py | from unittest import TestCase
from django.db import DatabaseError
from regressiontests.max_lengths.models import PersonWithDefaultMaxLengths, PersonWithCustomMaxLengths
class MaxLengthArgumentsTests(TestCase):
def verify_max_length(self, model,field,length):
self.assertEquals(model._meta.get_field... | 1,615 | Python | .py | 29 | 46.758621 | 102 | 0.693095 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,236 | extraction.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/makemessages/extraction.py | import os
import re
import shutil
from django.test import TestCase
from django.core import management
LOCALE='de'
class ExtractorTests(TestCase):
PO_FILE='locale/%s/LC_MESSAGES/django.po' % LOCALE
def setUp(self):
self._cwd = os.getcwd()
self.test_dir = os.path.abspath(os.path.dirname(__file... | 3,927 | Python | .py | 83 | 39.012048 | 109 | 0.654793 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,237 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/makemessages/tests.py | import os
import re
from subprocess import Popen, PIPE
def find_command(cmd, path=None, pathext=None):
if path is None:
path = os.environ.get('PATH', []).split(os.pathsep)
if isinstance(path, basestring):
path = [path]
# check if there are funny path extensions for executables, e.g. Windows... | 1,419 | Python | .py | 38 | 30.605263 | 134 | 0.618564 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,238 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/one_to_one_regress/models.py | from django.db import models
class Place(models.Model):
name = models.CharField(max_length=50)
address = models.CharField(max_length=80)
def __unicode__(self):
return u"%s the place" % self.name
class Restaurant(models.Model):
place = models.OneToOneField(Place)
serves_hot_dogs = models.B... | 1,180 | Python | .py | 31 | 33.322581 | 58 | 0.718558 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,239 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/one_to_one_regress/tests.py | from django.test import TestCase
from regressiontests.one_to_one_regress.models import *
class OneToOneRegressionTests(TestCase):
def setUp(self):
self.p1 = Place(name='Demon Dogs', address='944 W. Fullerton')
self.p1.save()
self.r1 = Restaurant(place=self.p1, serves_hot_dogs=True, serves_... | 4,691 | Python | .py | 107 | 34.327103 | 85 | 0.632098 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,240 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/csrf_tests/tests.py | # -*- coding: utf-8 -*-
from django.test import TestCase
from django.http import HttpRequest, HttpResponse
from django.middleware.csrf import CsrfMiddleware, CsrfViewMiddleware
from django.views.decorators.csrf import csrf_exempt, csrf_view_exempt, requires_csrf_token
from django.core.context_processors import csrf
fr... | 15,523 | Python | .py | 324 | 40.123457 | 107 | 0.662464 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,241 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/null_fk/models.py | """
Regression tests for proper working of ForeignKey(null=True).
"""
from django.db import models
class SystemDetails(models.Model):
details = models.TextField()
class SystemInfo(models.Model):
system_details = models.ForeignKey(SystemDetails)
system_name = models.CharField(max_length=32)
class Forum(m... | 847 | Python | .py | 24 | 30.916667 | 61 | 0.727273 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,242 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/null_fk/tests.py | from django.test import TestCase
from regressiontests.null_fk.models import *
class NullFkTests(TestCase):
def test_null_fk(self):
d = SystemDetails.objects.create(details='First details')
s = SystemInfo.objects.create(system_name='First forum', system_details=d)
f = Forum.objects.create(... | 1,868 | Python | .py | 35 | 43.142857 | 105 | 0.623768 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,243 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/bug639/models.py | import tempfile
from django.db import models
from django.core.files.storage import FileSystemStorage
from django.forms import ModelForm
temp_storage_dir = tempfile.mkdtemp()
temp_storage = FileSystemStorage(temp_storage_dir)
class Photo(models.Model):
title = models.CharField(max_length=30)
image = models.Fi... | 821 | Python | .py | 20 | 36.35 | 75 | 0.718239 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,244 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/bug639/tests.py | """
Tests for file field behavior, and specifically #639, in which Model.save()
gets called *again* for each FileField. This test will fail if calling a
ModelForm's save() method causes Model.save() to be called more than once.
"""
import os
import shutil
import unittest
from django.core.files.uploadedfile import Sim... | 1,327 | Python | .py | 33 | 33.878788 | 76 | 0.667185 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,245 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/managers_regress/models.py | """
Various edge-cases for model managers.
"""
from django.db import models
class OnlyFred(models.Manager):
def get_query_set(self):
return super(OnlyFred, self).get_query_set().filter(name='fred')
class OnlyBarney(models.Manager):
def get_query_set(self):
return super(OnlyBarney, self).get_q... | 2,430 | Python | .py | 71 | 29.492958 | 78 | 0.71073 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,246 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/managers_regress/tests.py | from django.test import TestCase
from models import Child1, Child2, Child3, Child4, Child5, Child6, Child7
class ManagersRegressionTests(TestCase):
def test_managers(self):
a1 = Child1.objects.create(name='fred', data='a1')
a2 = Child1.objects.create(name='barney', data='a2')
b1 = Child2.... | 2,544 | Python | .py | 47 | 43.957447 | 83 | 0.608434 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,247 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/admin_registration/models.py | """
Tests for various ways of registering models with the admin site.
"""
from django.db import models
class Person(models.Model):
name = models.CharField(max_length=200)
class Place(models.Model):
name = models.CharField(max_length=200)
| 249 | Python | .py | 8 | 28.75 | 65 | 0.768908 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,248 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/admin_registration/tests.py | from django.test import TestCase
from django.contrib import admin
from models import Person, Place
class NameAdmin(admin.ModelAdmin):
list_display = ['name']
save_on_top = True
class TestRegistration(TestCase):
def setUp(self):
self.site = admin.AdminSite()
def test_bare_registration(self):... | 2,001 | Python | .py | 44 | 35.977273 | 77 | 0.649718 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,249 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/servers/tests.py | """
Tests for django.core.servers.
"""
import os
import django
from django.test import TestCase
from django.core.handlers.wsgi import WSGIHandler
from django.core.servers.basehttp import AdminMediaHandler
class AdminMediaHandlerTests(TestCase):
def setUp(self):
self.admin_media_file_path = os.path.absp... | 2,299 | Python | .py | 61 | 26.344262 | 78 | 0.522636 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,250 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/bash_completion/tests.py | """
A series of tests to establish that the command-line bash completion works.
"""
import os
import unittest
import sys
import StringIO
from django.conf import settings
from django.core.management import ManagementUtility
class BashCompletionTests(unittest.TestCase):
"""
Testing the Python level bash complet... | 3,185 | Python | .py | 74 | 35.594595 | 128 | 0.662363 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,251 | test_command.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/regressiontests/bash_completion/management/commands/test_command.py | import sys, os
from optparse import OptionParser, make_option
from django.core.management.base import BaseCommand
class Command(BaseCommand):
option_list = BaseCommand.option_list + (
make_option("--list", action="store_true", dest="list",
help="Print all options"),
)
def han... | 362 | Python | .py | 10 | 30 | 63 | 0.672414 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,252 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/model_inheritance/models.py | """
XX. Model inheritance
Model inheritance exists in two varieties:
- abstract base classes which are a way of specifying common
information inherited by the subclasses. They don't exist as a separate
model.
- non-abstract base classes (the default), which are models in their own
right with ... | 3,888 | Python | .py | 111 | 30.441441 | 89 | 0.702811 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,253 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/model_inheritance/tests.py | from operator import attrgetter
from django.conf import settings
from django.core.exceptions import FieldError
from django.db import connection
from django.test import TestCase
from models import (Chef, CommonInfo, ItalianRestaurant, ParkingLot, Place,
Post, Restaurant, Student, StudentWorker, Supplier, Worker, M... | 10,909 | Python | .py | 250 | 33.224 | 140 | 0.613589 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,254 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/user_commands/models.py | """
38. User-registered management commands
The ``manage.py`` utility provides a number of useful commands for managing a
Django project. If you want to add a utility command of your own, you can.
The user-defined command ``dance`` is defined in the management/commands
subdirectory of this test application. It is a s... | 600 | Python | .py | 11 | 53.272727 | 78 | 0.795222 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,255 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/user_commands/tests.py | from StringIO import StringIO
from django.test import TestCase
from django.core import management
from django.core.management.base import CommandError
class CommandTests(TestCase):
def test_command(self):
out = StringIO()
management.call_command('dance', stdout=out)
self.assertEquals(out.g... | 708 | Python | .py | 17 | 35.058824 | 78 | 0.694767 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,256 | dance.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/user_commands/management/commands/dance.py | from optparse import make_option
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = "Dance around like a madman."
args = ''
requires_model_validation = True
option_list =[
make_option("-s", "--style", default="Rock'n'Roll")
]
def handle(self, *args,... | 411 | Python | .py | 11 | 32.454545 | 77 | 0.672544 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,257 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/files/models.py | """
42. Storing files according to a custom storage system
``FileField`` and its variations can take a ``storage`` argument to specify how
and where files should be stored.
"""
import random
import tempfile
from django.db import models
from django.core.files.base import ContentFile
from django.core.files.storage imp... | 1,206 | Python | .py | 25 | 44.64 | 100 | 0.760239 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,258 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/files/tests.py | import shutil
from django.core.cache import cache
from django.core.files.base import ContentFile
from django.core.files.uploadedfile import SimpleUploadedFile
from django.test import TestCase
from models import Storage, temp_storage, temp_storage_location
class FileTests(TestCase):
def tearDown(self):
s... | 3,920 | Python | .py | 80 | 40.3125 | 100 | 0.655849 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,259 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/one_to_one/models.py | """
10. One-to-one relationships
To define a one-to-one relationship, use ``OneToOneField()``.
In this example, a ``Place`` optionally can be a ``Restaurant``.
"""
from django.db import models, transaction, IntegrityError
class Place(models.Model):
name = models.CharField(max_length=50)
address = models.Cha... | 1,408 | Python | .py | 34 | 36.970588 | 68 | 0.719324 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,260 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/one_to_one/tests.py | from django.test import TestCase
from django.db import transaction, IntegrityError
from models import Place, Restaurant, Waiter, ManualPrimaryKey, RelatedModel, MultiModel
class OneToOneTests(TestCase):
def setUp(self):
self.p1 = Place(name='Demon Dogs', address='944 W. Fullerton')
self.p1.save()
... | 5,714 | Python | .py | 109 | 43.165138 | 95 | 0.657909 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,261 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/test_client/models.py | # coding: utf-8
"""
39. Testing using the Test Client
The test client is a class that can act like a simple
browser for testing purposes.
It allows the user to compose GET and POST requests, and
obtain the response that the server gave to those requests.
The server Response objects are annotated with the details
of t... | 20,977 | Python | .py | 373 | 47.450402 | 148 | 0.673736 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,262 | urls.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/test_client/urls.py | from django.conf.urls.defaults import *
from django.views.generic.simple import redirect_to
import views
urlpatterns = patterns('',
(r'^get_view/$', views.get_view),
(r'^post_view/$', views.post_view),
(r'^header_view/$', views.view_with_header),
(r'^raw_post_view/$', views.raw_post_view),
(r'^redi... | 1,592 | Python | .py | 28 | 52.535714 | 104 | 0.669866 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,263 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/test_client/tests.py | # Validate that you can override the default test suite
import unittest
def suite():
"""
Define a suite that deliberately ignores a test defined in
this module.
"""
testSuite = unittest.TestSuite()
testSuite.addTest(SampleTests('testGoodStuff'))
return testSuite
class SampleTests... | 465 | Python | .py | 15 | 25.133333 | 62 | 0.72028 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,264 | views.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/test_client/views.py | from xml.dom.minidom import parseString
from django.core import mail
from django.template import Context, Template
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseNotFound
from django.contrib.auth.decorators import login_required, permission_required
from django.forms.forms import Form
from dja... | 7,858 | Python | .py | 182 | 36.521978 | 128 | 0.662873 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,265 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/transactions/models.py | """
15. Transactions
Django handles transactions in three different ways. The default is to commit
each transaction upon a write, but you can decorate a function to get
commit-on-success behavior. Alternatively, you can manage the transaction
manually.
"""
from django.db import models, DEFAULT_DB_ALIAS
class Reporte... | 617 | Python | .py | 16 | 35.0625 | 77 | 0.735343 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,266 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/transactions/tests.py | from django.test import TransactionTestCase
from django.db import connection, transaction, IntegrityError, DEFAULT_DB_ALIAS
from django.conf import settings
from models import Reporter
PGSQL = 'psycopg2' in settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE']
MYSQL = 'mysql' in settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'... | 6,102 | Python | .py | 134 | 33.067164 | 116 | 0.597108 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,267 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/model_inheritance_same_model_name/models.py | """
XX. Model inheritance
Model inheritance across apps can result in models with the same name resulting
in the need for an %(app_label)s format string. This app specifically tests
this feature by redefining the Copy model from model_inheritance/models.py
"""
from django.db import models
from modeltests.model_inheri... | 509 | Python | .py | 15 | 31.6 | 79 | 0.789796 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,268 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/model_inheritance_same_model_name/tests.py | from django.test import TestCase
from modeltests.model_inheritance.models import Title
class InheritanceSameModelNameTests(TestCase):
def setUp(self):
# The Title model has distinct accessors for both
# model_inheritance.Copy and model_inheritance_same_model_name.Copy
# models.
sel... | 1,510 | Python | .py | 27 | 45.851852 | 97 | 0.67253 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,269 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/field_defaults/models.py | # coding: utf-8
"""
32. Callable defaults
You can pass callable objects as the ``default`` parameter to a field. When
the object is created without an explicit value passed in, Django will call
the method to determine the default value.
This example uses ``datetime.datetime.now`` as the default for the ``pub_date``
f... | 611 | Python | .py | 16 | 35.625 | 79 | 0.767797 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,270 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/field_defaults/tests.py | from datetime import datetime
from django.test import TestCase
from models import Article
class DefaultTests(TestCase):
def test_field_defaults(self):
a = Article()
now = datetime.now()
a.save()
self.assertTrue(isinstance(a.id, (int, long)))
self.assertEqual(a.headline, ... | 396 | Python | .py | 11 | 29.818182 | 56 | 0.681579 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,271 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/properties/models.py | """
22. Using properties on models
Use properties on models just like on any other Python object.
"""
from django.db import models
class Person(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
def _get_full_name(self):
return "%s %s" % (self... | 567 | Python | .py | 14 | 36.142857 | 69 | 0.697802 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,272 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/properties/tests.py | from django.test import TestCase
from models import Person
class PropertyTests(TestCase):
def setUp(self):
self.a = Person(first_name='John', last_name='Lennon')
self.a.save()
def test_getter(self):
self.assertEqual(self.a.full_name, 'John Lennon')
def test_setter(self):
... | 665 | Python | .py | 15 | 37.4 | 89 | 0.662016 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,273 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/m2m_and_m2o/models.py | """
29. Many-to-many and many-to-one relationships to the same table
Make sure to set ``related_name`` if you use relationships to the same table.
"""
from django.db import models
class User(models.Model):
username = models.CharField(max_length=20)
class Issue(models.Model):
num = models.IntegerField()
... | 573 | Python | .py | 15 | 34.133333 | 79 | 0.713768 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,274 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/m2m_and_m2o/tests.py | from django.db.models import Q
from django.test import TestCase
from models import Issue, User
class RelatedObjectTests(TestCase):
def test_m2m_and_m2o(self):
r = User.objects.create(username="russell")
g = User.objects.create(username="gustav")
i1 = Issue(num=1)
i1.client = r
... | 1,938 | Python | .py | 67 | 17.537313 | 91 | 0.469673 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,275 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/aggregation/models.py | # coding: utf-8
from django.db import models
class Author(models.Model):
name = models.CharField(max_length=100)
age = models.IntegerField()
friends = models.ManyToManyField('self', blank=True)
def __unicode__(self):
return self.name
class Publisher(models.Model):
name = models.CharField... | 1,181 | Python | .py | 32 | 31.84375 | 72 | 0.710272 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,276 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/aggregation/tests.py | import datetime
from decimal import Decimal
from django.db.models import Avg, Sum, Count, Max, Min
from django.test import TestCase, Approximate
from models import Author, Publisher, Book, Store
class BaseAggregateTestCase(TestCase):
fixtures = ["initial_data.json"]
def test_empty_aggregate(self):
... | 20,519 | Python | .py | 505 | 27.180198 | 155 | 0.502205 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,277 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/get_latest/models.py | """
8. get_latest_by
Models can have a ``get_latest_by`` attribute, which should be set to the name
of a ``DateField`` or ``DateTimeField``. If ``get_latest_by`` exists, the
model's manager will get a ``latest()`` method, which will return the latest
object in the database according to that field. "Latest" means "havi... | 871 | Python | .py | 23 | 33.956522 | 79 | 0.705113 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,278 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/get_latest/tests.py | from datetime import datetime
from django.test import TestCase
from models import Article, Person
class LatestTests(TestCase):
def test_latest(self):
# Because no Articles exist yet, latest() raises ArticleDoesNotExist.
self.assertRaises(Article.DoesNotExist, Article.objects.latest)
a1 ... | 2,033 | Python | .py | 44 | 36.818182 | 93 | 0.634343 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,279 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/validators/tests.py | # -*- coding: utf-8 -*-
import re
import types
from unittest import TestCase
from datetime import datetime, timedelta
from django.core.exceptions import ValidationError
from django.core.validators import *
NOW = datetime.now()
TEST_DATA = (
# (validator, value, expected),
(validate_integer, '42', None),
(... | 6,299 | Python | .py | 129 | 43.44186 | 92 | 0.666884 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,280 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/basic/models.py | # coding: utf-8
"""
1. Bare-bones model
This is a basic model with only two non-primary-key fields.
"""
from django.db import models, DEFAULT_DB_ALIAS
class Article(models.Model):
headline = models.CharField(max_length=100, default='Default headline')
pub_date = models.DateTimeField()
class Meta:
... | 413 | Python | .py | 13 | 28 | 75 | 0.707071 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,281 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/basic/tests.py | from datetime import datetime
import re
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django.db import models, DEFAULT_DB_ALIAS, connection
from django.db.models.fields import FieldDoesNotExist
from django.test import TestCase
from models import Article
class ModelTest(... | 22,120 | Python | .py | 488 | 34.606557 | 117 | 0.590315 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,282 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/many_to_one_null/models.py | """
16. Many-to-one relationships that can be null
To define a many-to-one relationship that can have a null foreign key, use
``ForeignKey()`` with ``null=True`` .
"""
from django.db import models
class Reporter(models.Model):
name = models.CharField(max_length=30)
def __unicode__(self):
return self... | 565 | Python | .py | 17 | 29 | 74 | 0.700555 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,283 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/many_to_one_null/tests.py | from django.test import TestCase
from models import Reporter, Article
class ManyToOneNullTests(TestCase):
def setUp(self):
# Create a Reporter.
self.r = Reporter(name='John Smith')
self.r.save()
# Create an Article.
self.a = Article(headline="First", reporter=self.r)
... | 4,174 | Python | .py | 76 | 43.763158 | 87 | 0.627139 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,284 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/custom_methods/models.py | """
3. Giving models custom methods
Any method you add to a model will be available to instances.
"""
from django.db import models
import datetime
class Article(models.Model):
headline = models.CharField(max_length=100)
pub_date = models.DateField()
def __unicode__(self):
return self.headline
... | 1,139 | Python | .py | 29 | 31.206897 | 81 | 0.635539 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,285 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/custom_methods/tests.py | from datetime import date
from django.test import TestCase
from models import Article
class MethodsTests(TestCase):
def test_custom_methods(self):
a = Article.objects.create(
headline="Area man programs in Python", pub_date=date(2005, 7, 27)
)
b = Article.objects.create(
... | 1,155 | Python | .py | 36 | 21.472222 | 78 | 0.539084 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,286 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/field_subclassing/models.py | """
Tests for field subclassing.
"""
from django.db import models
from django.utils.encoding import force_unicode
from fields import Small, SmallField, SmallerField, JSONField
class MyModel(models.Model):
name = models.CharField(max_length=10)
data = SmallField('small field')
def __unicode__(self):
... | 471 | Python | .py | 15 | 28.066667 | 61 | 0.752784 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,287 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/field_subclassing/tests.py | from django.core import serializers
from django.test import TestCase
from fields import Small
from models import DataModel, MyModel, OtherModel
class CustomField(TestCase):
def test_defer(self):
d = DataModel.objects.create(data=[1, 2, 3])
self.assertTrue(isinstance(d.data, list))
d = D... | 2,795 | Python | .py | 63 | 35.142857 | 124 | 0.605011 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,288 | fields.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/field_subclassing/fields.py | from django.core.exceptions import FieldError
from django.db import models
from django.utils import simplejson as json
from django.utils.encoding import force_unicode
class Small(object):
"""
A simple class to show that non-trivial Python objects can be used as
attributes.
"""
def __init__(self, f... | 2,131 | Python | .py | 57 | 30.333333 | 81 | 0.646087 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,289 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/raw_query/models.py | from django.db import models
class Author(models.Model):
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
dob = models.DateField()
def __init__(self, *args, **kwargs):
super(Author, self).__init__(*args, **kwargs)
# Protect against annotations ... | 1,016 | Python | .py | 24 | 36.416667 | 69 | 0.682556 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,290 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/raw_query/tests.py | from datetime import date
from django.conf import settings
from django.db import connection
from django.db.models.sql.query import InvalidQuery
from django.test import TestCase
from models import Author, Book, Coffee, Reviewer, FriendlyAuthor
class RawQueryTests(TestCase):
fixtures = ['raw_query_books.json']
... | 9,056 | Python | .py | 202 | 35.247525 | 190 | 0.636395 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,291 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/str/models.py | # -*- coding: utf-8 -*-
"""
2. Adding __str__() or __unicode__() to models
Although it's not a strict requirement, each model should have a
``_str__()`` or ``__unicode__()`` method to return a "human-readable"
representation of the object. Do this not only for your own sanity when dealing
with the interactive prompt, ... | 1,213 | Python | .py | 26 | 43.269231 | 79 | 0.719729 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,292 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/str/tests.py | # -*- coding: utf-8 -*-
import datetime
from django.test import TestCase
from models import Article, InternationalArticle
class SimpleTests(TestCase):
def test_basic(self):
a = Article.objects.create(
headline='Area man programs in Python',
pub_date=datetime.datetime(2005, 7, 28)... | 834 | Python | .py | 19 | 36.368421 | 85 | 0.656404 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,293 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/force_insert_update/models.py | """
Tests for forcing insert and update queries (instead of Django's normal
automatic behaviour).
"""
from django.db import models, transaction, IntegrityError
class Counter(models.Model):
name = models.CharField(max_length = 10)
value = models.IntegerField()
class WithCustomPK(models.Model):
name = model... | 387 | Python | .py | 11 | 32.545455 | 71 | 0.772727 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,294 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/force_insert_update/tests.py | from django.db import transaction, IntegrityError, DatabaseError
from django.test import TestCase
from models import Counter, WithCustomPK
class ForceTests(TestCase):
def test_force_update(self):
c = Counter.objects.create(name="one", value=1)
# The normal case
c.value = 2
c.save... | 1,336 | Python | .py | 30 | 36.466667 | 83 | 0.667951 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,295 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/choices/models.py | """
21. Specifying 'choices' for a field
Most fields take a ``choices`` parameter, which should be a tuple of tuples
specifying which are the valid values for that field.
For each field that has ``choices``, a model instance gets a
``get_fieldname_display()`` method, where ``fieldname`` is the name of the
field. This... | 666 | Python | .py | 18 | 34.111111 | 75 | 0.718069 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,296 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/choices/tests.py | from django.test import TestCase
from models import Person
class ChoicesTests(TestCase):
def test_display(self):
a = Person.objects.create(name='Adrian', gender='M')
s = Person.objects.create(name='Sara', gender='F')
self.assertEqual(a.gender, 'M')
self.assertEqual(s.gender, 'F')
... | 742 | Python | .py | 16 | 37.6875 | 74 | 0.647226 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,297 | models.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/order_with_respect_to/models.py | """
Tests for the order_with_respect_to Meta attribute.
"""
from django.db import models
class Question(models.Model):
text = models.CharField(max_length=200)
class Answer(models.Model):
text = models.CharField(max_length=200)
question = models.ForeignKey(Question)
class Meta:
order_with_re... | 663 | Python | .py | 20 | 28.3 | 74 | 0.698738 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,298 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/order_with_respect_to/tests.py | from operator import attrgetter
from django.test import TestCase
from models import Post, Question, Answer
class OrderWithRespectToTests(TestCase):
def test_basic(self):
q1 = Question.objects.create(text="Which Beatle starts with the letter 'R'?")
q2 = Question.objects.create(text="What is your ... | 2,870 | Python | .py | 59 | 38.423729 | 85 | 0.62304 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |
3,299 | tests.py | gabrielfalcao_lettuce/tests/integration/lib/Django-1.2.5/tests/modeltests/proxy_model_inheritance/tests.py | """
XX. Proxy model inheritance
Proxy model inheritance across apps can result in syncdb not creating the table
for the proxied model (as described in #12286). This test creates two dummy
apps and calls syncdb, then verifies that the table has been created.
"""
import os
import sys
from django.conf import settings,... | 1,255 | Python | .py | 29 | 38.034483 | 79 | 0.735029 | gabrielfalcao/lettuce | 1,274 | 325 | 102 | GPL-3.0 | 9/5/2024, 5:08:58 PM (Europe/Amsterdam) |