repo_id
stringclasses
409 values
prefix
large_stringlengths
34
36.3k
target
large_stringlengths
1
498
assertion_type
stringclasses
31 values
difficulty
stringclasses
8 values
test_file
stringlengths
10
121
test_function
stringlengths
1
104
test_class
stringlengths
0
51
lineno
int32
2
11.3k
commit_idx
int32
django-extensions/django-extensions
from django.test import TestCase from django_extensions.db.fields.json import dumps, loads, JSONField, JSONDict, JSONList from .testapp.models import JSONFieldTestModel class JsonFieldTest(TestCase): def test_char_field_create(self): j = JSONFieldTestModel.objects.create(a=6, j_field=dict(foo="bar")) ...
6)
self.assertEqual
numeric_literal
tests/test_json_field.py
test_char_field_create
JsonFieldTest
9
null
django-extensions/django-extensions
from django.core import mail from django.core.management import call_command from django.test import TestCase from django.test.utils import override_settings from io import StringIO from unittest.mock import patch class EmailNotificationCommandTests(TestCase): @override_settings( ADMINS=["foo@bar.com", "...
mail.outbox[0].body)
self.assertIn
complex_expr
tests/management/test_email_notifications.py
test_should_send_email_with_command_name_and_full_traceback_if_command_fail
EmailNotificationCommandTests
46
null
django-extensions/django-extensions
import fnmatch import os from io import StringIO from django.core.management import call_command from django.test import TestCase class CompilePycTests(TestCase): def setUp(self): self.project_root = os.path.join("tests", "testapp") self._settings = os.environ.get("DJANGO_SETTINGS_MODULE") ...
len(pyc_glob) > 0)
self.assertTrue
func_call
tests/test_compile_pyc.py
test_compiles_pyc_files
CompilePycTests
34
null
django-extensions/django-extensions
from io import StringIO from django.core.management import CommandError, call_command from django.test import TestCase from django.test.utils import override_settings from unittest.mock import patch MYSQL_DATABASE_SETTINGS = { "ENGINE": "django.db.backends.mysql", "NAME": "dbatabase", "USER": "foo", ...
m_stdout.getvalue())
self.assertEqual
func_call
tests/management/commands/test_sqldsn.py
test_should_print_info_for_default_sqlite3_database
SqlDsnTests
82
null
django-extensions/django-extensions
import os import html import shutil from tempfile import mkdtemp from django.template import Context, Template from django.test import TestCase from django_extensions.templatetags.syntax_color import generate_pygments_css class SyntaxColorTagTests(TestCase): def setUpClass(cls): cls.tmpdir = mkdtemp() ...
result)
self.assertIn
variable
tests/templatetags/test_syntax_color.py
test_pygments_css_should_return_highlight_css
SyntaxColorTagTests
35
null
django-extensions/django-extensions
from unittest import mock import pytest from io import StringIO from django.conf import settings from django.apps import apps from django.test import TestCase from django_extensions.management.commands.sqldiff import ( SqliteSQLDiff, Command, MySQLDiff, PostgresqlSQLDiff, ) from tests.testapp.models i...
[("random_char_field", "common_field")])
self.assertEqual
collection
tests/test_sqldiff.py
test_get_unique_together
SqlDiffTests
107
null
django-extensions/django-extensions
import sys from django.contrib.auth.models import Group, Permission from django.test import override_settings from django_extensions.collision_resolvers import ( AppNameCR, AppsOrderCR, BaseCR, PathBasedCR, ) from tests.collisions.models import Group as Group_Col from tests.collisions.models import Nam...
name)
assert_*
variable
tests/management/commands/shell_plus_tests/test_collision_resolver.py
_assert_models_present_under_names
CRTestCase
88
null
django-extensions/django-extensions
import os import pytest from django.contrib.auth.models import User from django.core.management import call_command, CommandError from django.test import TestCase from django.test.utils import override_settings from io import StringIO from unittest.mock import patch TEST_FIXTURE_DIR = os.path.join(os.path.dirname(__...
m_stdout.getvalue())
self.assertEqual
func_call
tests/management/commands/test_syncdata.py
test_should_print_No_fixtures_found_if_fixture_labels_not_provided
SyncDataTests
70
null
django-extensions/django-extensions
import importlib.util from io import StringIO from unittest.mock import MagicMock, Mock, PropertyMock, call, patch from django.core.management import CommandError, call_command from django.test import TestCase from django.test.utils import override_settings UNKOWN_ENGINE = { "default": { "ENGINE": "django...
[call("test_db.sqlite3")])
self.assertListEqual
collection
tests/management/commands/test_drop_test_database.py
test_sqlite3_should_unlink_primary_test_database
DropTestDatabaseTests
125
null
django-extensions/django-extensions
import pytest from django.core.management import CommandError, call_command def test_without_args(capsys): call_command("print_settings") out, err = capsys.readouterr() assert "DEBUG" in
out
assert
variable
tests/management/commands/test_print_settings.py
test_without_args
9
null
django-extensions/django-extensions
import os from unittest import mock import logging import importlib from django.core.management import ( call_command, find_commands, load_command_class, BaseCommand, ) from django.test import TestCase from io import StringIO from django_extensions.management.modelviz import use_model, generate_graph_...
output)
self.assertIn
variable
tests/test_management_command.py
test_some_output
ShowTemplateTagsTests
80
null
django-extensions/django-extensions
from unittest import mock from django.db import models from django.test import TestCase from tests.testapp.models import ( DummyRelationModel, InheritedFromPostWithUniqFieldCompat, PostWithUniqFieldCompat, ReverseModelCompat, SecondDummyRelationModel, ThirdDummyRelationModel, ) from django_ext...
field)
assert_*
variable
tests/db/fields/test_uniq_field_mixin_compat.py
test_find_unique
UniqFieldMixinCompatTestCase
159
null
django-extensions/django-extensions
import os import shutil from django.conf import settings from django.core.management import CommandError, call_command from django.test import TestCase from django.test.utils import override_settings from io import StringIO from django_extensions.management.commands.sync_s3 import Command from unittest.mock import M...
m_stdout.getvalue())
self.assertIn
func_call
tests/management/commands/test_sync_s3.py
test_should_raise_CommandError_when_medi
SyncS3CommandTests
243
null
django-extensions/django-extensions
import sys from django.contrib.auth.models import Group, Permission from django.test import override_settings from django_extensions.collision_resolvers import ( AppNameCR, AppsOrderCR, BaseCR, PathBasedCR, ) from tests.collisions.models import Group as Group_Col from tests.collisions.models import Nam...
note)
assert_*
variable
tests/management/commands/shell_plus_tests/test_collision_resolver.py
_assert_models_present_under_names
CRTestCase
90
null
django-extensions/django-extensions
import os from unittest import mock import logging import importlib from django.core.management import ( call_command, find_commands, load_command_class, BaseCommand, ) from django.test import TestCase from io import StringIO from django_extensions.management.modelviz import use_model, generate_graph_...
5)
self.assertEqual
numeric_literal
tests/test_management_command.py
test_merge_model_instances
MergeModelInstancesTests
556
null
django-extensions/django-extensions
from django.test import TestCase from .testapp.models import ( ShortUUIDTestAgregateModel, ShortUUIDTestManyToManyModel, ShortUUIDTestModel_field, ShortUUIDTestModel_pk, ) class ShortUUIDFieldTest(TestCase): def test_UUID_field_pk_agregate_create(self): j = ShortUUIDTestAgregateModel.obje...
6)
self.assertEqual
numeric_literal
tests/test_shortuuid_field.py
test_UUID_field_pk_agregate_create
ShortUUIDFieldTest
25
null
django-extensions/django-extensions
from unittest import mock import pytest from io import StringIO from django.conf import settings from django.apps import apps from django.test import TestCase from django_extensions.management.commands.sqldiff import ( SqliteSQLDiff, Command, MySQLDiff, PostgresqlSQLDiff, ) from tests.testapp.models i...
[("aaa", "bbb")])
self.assertEqual
collection
tests/test_sqldiff.py
test_get_unique_together
SqlDiffTests
111
null
django-extensions/django-extensions
from unittest import mock import pytest from io import StringIO from django.conf import settings from django.apps import apps from django.test import TestCase from django_extensions.management.commands.sqldiff import ( SqliteSQLDiff, Command, MySQLDiff, PostgresqlSQLDiff, ) from tests.testapp.models i...
[("number", "creator")])
self.assertEqual
collection
tests/test_sqldiff.py
test_get_index_together
SqlDiffTests
89
null
django-extensions/django-extensions
from unittest import mock from django.db import models from django.test import TestCase from tests.testapp.models import ( DummyRelationModel, InheritedFromPostWithUniqFieldCompat, PostWithUniqFieldCompat, ReverseModelCompat, SecondDummyRelationModel, ThirdDummyRelationModel, ) from django_ext...
tuple)
self.assertIsInstance
variable
tests/db/fields/test_uniq_field_mixin_compat.py
test__get_fields_returns_list_of_tulpes
UniqFieldMixinCompatTestCase
70
null
django-extensions/django-extensions
from io import StringIO from django.urls import path from django.core.management import CommandError, call_command from django.http import HttpResponse from django.test import TestCase from django.test.utils import override_settings from django.views.generic.base import View from unittest.mock import Mock, patch def...
m_stdout.getvalue())
self.assertIn
func_call
tests/management/commands/test_show_urls.py
test_should_show_urls_in_table_format
ShowUrlsTests
157
null
django-extensions/django-extensions
from unittest.mock import patch from django.core.exceptions import ValidationError from django.test import TestCase, SimpleTestCase from django_extensions.validators import ( NoControlCharactersValidator, NoWhitespaceValidator, HexValidator, ) class TestHexValidator(SimpleTestCase): def test_equalit...
HexValidator())
self.assertNotEqual
func_call
tests/test_validators.py
test_equality_of_objs_with_obj_of_different_type
TestHexValidator
115
null
django-extensions/django-extensions
from unittest.mock import patch from django.core.exceptions import ValidationError from django.test import TestCase, SimpleTestCase from django_extensions.validators import ( NoControlCharactersValidator, NoWhitespaceValidator, HexValidator, ) class NoWhiteSpaceValidatorTests(TestCase): def test_sho...
"no_whitespace")
self.assertEqual
string_literal
tests/test_validators.py
test_should_raise_default_message_and_code_if_value_has_leading_whitespace
NoWhiteSpaceValidatorTests
74
null
django-extensions/django-extensions
from django.test import TestCase from django_extensions.db.models import ActivatorModel from .testapp.models import Post class ActivatorModelTestCase(TestCase): def test_inactive_includes_inactive(self): post = Post.objects.create(status=ActivatorModel.INACTIVE_STATUS) inactive = Post.objects.in...
inactive)
self.assertIn
variable
tests/test_models.py
test_inactive_includes_inactive
ActivatorModelTestCase
24
null
django-extensions/django-extensions
import os import shutil from django.core.management import call_command from django.test import TestCase from io import StringIO from tests import testapp_with_no_models_file from unittest.mock import patch JOBS_DIR = os.path.join(testapp_with_no_models_file.__path__[0], "jobs") TIME_PERIODS = ["hourly", "daily", "w...
os.path.exists(JOBS_DIR))
self.assertTrue
func_call
tests/management/commands/test_create_jobs.py
test_should_create_jobs_directory_structure_silently
CreateJobsTests
44
null
django-extensions/django-extensions
import os import shutil from django.conf import settings from django.core.management import CommandError, call_command from django.test import TestCase from django.test.utils import override_settings from io import StringIO from django_extensions.management.commands.sync_s3 import Command from unittest.mock import M...
CommandError, "MEDIA_ROOT must be set in your settings.")
self.assertRaisesRegex
complex_expr
tests/management/commands/test_sync_s3.py
test_should_raise_CommandError_if_MEDIA_ROOT_is_None
SyncS3ExceptionsTests
91
null
django-extensions/django-extensions
from io import StringIO from django.core.management import call_command from django.db import models from django.test import TestCase class AdminGeneratorTests(TestCase): def setUp(self): self.out = StringIO() def test_should_print_admin_class_for_User_model_only(self): call_command("admin_g...
self.out.getvalue())
self.assertIn
func_call
tests/management/commands/test_admin_generator.py
test_should_print_admin_class_for_User_model_only
AdminGeneratorTests
34
null
django-extensions/django-extensions
from io import StringIO from django.urls import path from django.core.management import CommandError, call_command from django.http import HttpResponse from django.test import TestCase from django.test.utils import override_settings from django.views.generic.base import View from unittest.mock import Mock, patch def...
lines[2])
self.assertIn
complex_expr
tests/management/commands/test_show_urls.py
test_should_show_urls_unsorted_but_same_order_as_found_in_url_patterns
ShowUrlsTests
73
null
django-extensions/django-extensions
import os import shutil from io import StringIO from tempfile import mkdtemp from django.conf import settings from django.core.management import CommandError, call_command from django.test import TestCase from django.test.utils import override_settings class ValidateTemplatesTests(TestCase): def setUp(self): ...
CommandError, "Errors found")
self.assertRaisesRegex
complex_expr
tests/management/commands/test_validate_templates.py
test_should_break_when_first_error_occur
ValidateTemplatesTests
74
null
django-extensions/django-extensions
import unittest from unittest.mock import Mock from django_extensions.management.shells import import_items class TestImportItems(unittest.TestCase): def setUp(self): self.style = Mock() self.style.ERROR = Mock(return_value="ERROR") self.style.SQL_COLTYPE = Mock(return_value="SQL_COLTYPE") ...
callable(result["cos"]))
self.assertTrue
func_call
tests/management/commands/shell_plus_tests/test_shells.py
test_from_import_star
TestImportItems
41
null
django-extensions/django-extensions
from io import StringIO from django.conf import settings from django.contrib.sites.models import Site from django.core.management import call_command from django.core.management.base import CommandError from django.test import TestCase from django.test.utils import override_settings from unittest.mock import patch c...
CommandError, "The sites framework is not installed.")
self.assertRaisesRegex
complex_expr
tests/management/commands/test_set_default_site.py
test_should_raise_CommandError_Sites_framework_not_installed
SetDefaultSiteTests
43
null
django-extensions/django-extensions
from django.test import TestCase from .testapp.models import ( ShortUUIDTestAgregateModel, ShortUUIDTestManyToManyModel, ShortUUIDTestModel_field, ShortUUIDTestModel_pk, ) class ShortUUIDFieldTest(TestCase): def test_UUID_field_pk_agregate_create(self): j = ShortUUIDTestAgregateModel.obje...
str)
self.assertIsInstance
variable
tests/test_shortuuid_field.py
test_UUID_field_pk_agregate_create
ShortUUIDFieldTest
26
null
django-extensions/django-extensions
from django.test import TestCase from django_extensions.db.fields.json import dumps, loads, JSONField, JSONDict, JSONList from .testapp.models import JSONFieldTestModel class JsonFieldTest(TestCase): def test_default(self): j = JSONFieldTestModel.objects.create(a=1) self.assertEqual(j.j_field,
{})
self.assertEqual
collection
tests/test_json_field.py
test_default
JsonFieldTest
31
null
django-extensions/django-extensions
import unittest from unittest.mock import Mock from django_extensions.management.shells import import_items class TestImportItems(unittest.TestCase): def setUp(self): self.style = Mock() self.style.ERROR = Mock(return_value="ERROR") self.style.SQL_COLTYPE = Mock(return_value="SQL_COLTYPE") ...
"json")
self.assertEqual
string_literal
tests/management/commands/shell_plus_tests/test_shells.py
test_import_with_alias
TestImportItems
27
null
django-extensions/django-extensions
import sys from io import StringIO from django.apps import apps from django.core.management import call_command from django.test import TestCase class ShowPermissionsTests(TestCase): def _run_command(self, *args, **kwargs): """ Utility to run the command and return captured output. """ ...
output)
self.assertNotIn
variable
tests/management/commands/test_show_permissions.py
test_should_list_permissions_for_all_apps_excluding_defaults
ShowPermissionsTests
44
null
django-extensions/django-extensions
from django.test import TestCase from django_extensions.db.fields.json import dumps, loads, JSONField, JSONDict, JSONList from .testapp.models import JSONFieldTestModel class JsonFieldTest(TestCase): def test_char_field_get_or_create(self): j, created = JSONFieldTestModel.objects.get_or_create( ...
created)
self.assertTrue
variable
tests/test_json_field.py
test_char_field_get_or_create
JsonFieldTest
17
null
django-extensions/django-extensions
from unittest import mock from django.db import models from django.test import TestCase from tests.testapp.models import ( DummyRelationModel, InheritedFromPostWithUniqField, PostWithUniqField, ReverseModel, SecondDummyRelationModel, ThirdDummyRelationModel, ) from django_extensions.db.fields ...
"b")
self.assertEqual
string_literal
tests/db/fields/test_uniq_field_mixin.py
test_find_unique
UniqFieldMixinTestCase
159
null
django-extensions/django-extensions
from django.core import mail from django.core.management import call_command from django.test import TestCase from django.test.utils import override_settings from io import StringIO from unittest.mock import patch class EmailNotificationCommandTests(TestCase): @override_settings( ADMINS=["foo@bar.com"], ...
["recipient0@example.com", "foo@bar.com"])
self.assertListEqual
collection
tests/management/test_email_notifications.py
test_should_notify_if_notification_level_is_greater_than_0
EmailNotificationCommandTests
78
null
django-extensions/django-extensions
from django.core import mail from django.core.management import call_command from django.test import TestCase from django.test.utils import override_settings from io import StringIO from unittest.mock import patch class EmailNotificationCommandTests(TestCase): @override_settings(ADMINS=[]) @patch("sys.stdout...
[])
self.assertListEqual
collection
tests/management/test_email_notifications.py
test_should_print_that_no_email_recipients_available
EmailNotificationCommandTests
22
null
django-extensions/django-extensions
from io import StringIO from django.core.management import CommandError, call_command from django.test import TestCase from django.test.utils import override_settings from unittest.mock import patch MYSQL_DATABASE_SETTINGS = { "ENGINE": "django.db.backends.mysql", "NAME": "dbatabase", "USER": "foo", ...
CommandError, "Unknown database unknown")
self.assertRaisesRegex
complex_expr
tests/management/commands/test_sqldsn.py
test_should_raise_CommandError_if_unknown_database_does_not_exist
SqlDsnExceptionsTests
65
null
django-extensions/django-extensions
from io import StringIO from django.core.management import CommandError, call_command from django.test import TestCase from django.test.utils import override_settings from unittest.mock import patch MYSQL_DATABASE_SETTINGS = { "ENGINE": "django.db.backends.mysql", "NAME": "dbatabase", "USER": "foo", ...
m_stderr.getvalue())
self.assertEqual
func_call
tests/management/commands/test_sqlcreate.py
test_should_print_SQL_create_database_statement_for_mysql
SqlCreateTests
72
null
django-extensions/django-extensions
from django.test import TestCase from django.template import Context, Template, TemplateSyntaxError class IndentByTagExceptions(TestCase): def test_should_raise_TemplateSyntaxError_if_args_lenght_not_in_2_4(self): content = """{% load indent_text %} {% indentby %} Hello World {% endindentby %}""" ...
TemplateSyntaxError, "indentby tag requires 1 or 3 arguments")
self.assertRaisesRegex
complex_expr
tests/templatetags/test_indent_text.py
test_should_raise_TemplateSyntaxError_if_args_lenght_not_in_2_4
IndentByTagExceptions
13
null
django-extensions/django-extensions
from unittest import mock import pytest from io import StringIO from django.conf import settings from django.apps import apps from django.test import TestCase from django_extensions.management.commands.sqldiff import ( SqliteSQLDiff, Command, MySQLDiff, PostgresqlSQLDiff, ) from tests.testapp.models i...
[("slug", "category")])
self.assertEqual
collection
tests/test_sqldiff.py
test_get_unique_together
SqlDiffTests
103
null
django-extensions/django-extensions
import string import pytest from django.test import TestCase from .testapp.models import ( RandomCharTestModel, RandomCharTestModelUnique, RandomCharTestModelLowercase, ) from .testapp.models import ( RandomCharTestModelUppercase, RandomCharTestModelAlpha, RandomCharTestModelDigits, ) from .te...
string.punctuation
assert
complex_expr
tests/test_randomchar_field.py
testRandomCharFieldPunctuation
RandomCharFieldTest
65
null
django-extensions/django-extensions
import pytest from django.db import migrations, models from django.db.migrations.writer import MigrationWriter from django.test import TestCase from django.utils.encoding import force_bytes import django_extensions # noqa from django_extensions.db.fields import AutoSlugField from .testapp.models import ( ChildS...
"foo")
self.assertEqual
string_literal
tests/test_autoslug_fields.py
test_auto_create_slug
AutoSlugFieldTest
39
null
django-extensions/django-extensions
from django.core import mail from django.core.management import call_command from django.test import TestCase from django.test.utils import override_settings from io import StringIO from unittest.mock import patch class EmailNotificationCommandTests(TestCase): @override_settings( ADMINS=["foo@bar.com", "...
["foo@bar.com", "bar@foo.com"])
self.assertListEqual
collection
tests/management/test_email_notifications.py
test_should_send_email_with_command_name_and_full_traceback_if_command_fail
EmailNotificationCommandTests
44
null
django-extensions/django-extensions
from django.core.cache import caches from django.core.management import call_command from django.test import TestCase from django.test.utils import override_settings class CacheCleanupTests(TestCase): @override_settings( CACHES={ "test_cache": { "BACKEND": "django.core.cache.ba...
db_cache.get("my_key"))
self.assertIsNone
func_call
tests/jobs/daily/test_cache_cleanup.py
test_remove_all_keys_from_DatabaseCache
CacheCleanupTests
28
null
django-extensions/django-extensions
import unittest from unittest.mock import Mock from django_extensions.management.shells import import_items class TestImportItems(unittest.TestCase): def setUp(self): self.style = Mock() self.style.ERROR = Mock(return_value="ERROR") self.style.SQL_COLTYPE = Mock(return_value="SQL_COLTYPE") ...
"http.client")
self.assertEqual
string_literal
tests/management/commands/shell_plus_tests/test_shells.py
test_dotted_import
TestImportItems
22
null
django-extensions/django-extensions
from io import StringIO import pytest from django.contrib.auth.models import User from django.core.management import CommandError, call_command from django_extensions.management.commands.set_fake_passwords import ( DEFAULT_FAKE_PASSWORD, ) from unittest.mock import Mock, patch def django_db_setup(django_db_setu...
out
assert
variable
tests/management/commands/test_set_fake_passwords.py
test_without_args
32
null
django-extensions/django-extensions
from io import StringIO import pytest from django.contrib.auth.models import User from django.core.management import CommandError, call_command from django_extensions.management.commands.set_fake_passwords import ( DEFAULT_FAKE_PASSWORD, ) from unittest.mock import Mock, patch def django_db_setup(django_db_setu...
CommandError, match="You must enter a valid password")
pytest.raises
complex_expr
tests/management/commands/test_set_fake_passwords.py
test_with_prompt_with_empty_password
74
null
django-extensions/django-extensions
import json import os import re import tempfile from contextlib import contextmanager from io import StringIO from django.core.management import call_command from django.core.management.base import CommandError from django.test import TestCase def assert_looks_like_dotfile(output): assert output.startswith("digra...
""
assert
string_literal
tests/management/commands/test_graph_models.py
test_graph_models_dot_option_to_file
GraphModelsOutputTests
64
null
django-extensions/django-extensions
from io import StringIO import pytest from django.contrib.auth.models import User from django.core.management import CommandError, call_command from django_extensions.management.commands.set_fake_passwords import ( DEFAULT_FAKE_PASSWORD, ) from unittest.mock import Mock, patch def django_db_setup(django_db_setu...
3
assert
numeric_literal
tests/management/commands/test_set_fake_passwords.py
test_without_args
28
null
django-extensions/django-extensions
import unittest from unittest.mock import Mock from django_extensions.management.shells import import_items class TestImportItems(unittest.TestCase): def setUp(self): self.style = Mock() self.style.ERROR = Mock(return_value="ERROR") self.style.SQL_COLTYPE = Mock(return_value="SQL_COLTYPE") ...
"defaultdict")
self.assertEqual
string_literal
tests/management/commands/shell_plus_tests/test_shells.py
test_from_import
TestImportItems
34
null
django-extensions/django-extensions
from io import StringIO import pytest from django.contrib.auth.models import User from django.core.management import CommandError, call_command from django_extensions.management.commands.set_fake_passwords import ( DEFAULT_FAKE_PASSWORD, ) from unittest.mock import Mock, patch def django_db_setup(django_db_setu...
CommandError, match="Only available in debug mode")
pytest.raises
complex_expr
tests/management/commands/test_set_fake_passwords.py
test_without_debug
83
null
django-extensions/django-extensions
from unittest.mock import patch from django.core.exceptions import ValidationError from django.test import TestCase, SimpleTestCase from django_extensions.validators import ( NoControlCharactersValidator, NoWhitespaceValidator, HexValidator, ) class NoControlCharactersValidatorTests(TestCase): def t...
"custom code")
self.assertEqual
string_literal
tests/test_validators.py
test_should_raise_custom_message_and_code_if_value_contains_tabs
NoControlCharactersValidatorTests
42
null
django-extensions/django-extensions
from io import StringIO from django.conf import settings from django.contrib.sites.models import Site from django.core.management import call_command from django.core.management.base import CommandError from django.test import TestCase from django.test.utils import override_settings from unittest.mock import patch c...
CommandError, "Cannot find systems FQDN")
self.assertRaisesRegex
complex_expr
tests/management/commands/test_set_default_site.py
test_should_raise_CommandError_if_system_fqdn_return_None
SetDefaultSiteTests
26
null
django-extensions/django-extensions
from django.test import TestCase from django_extensions.db.fields.json import dumps, loads, JSONField, JSONDict, JSONList from .testapp.models import JSONFieldTestModel class JsonFieldTest(TestCase): def test_char_field_create(self): j = JSONFieldTestModel.objects.create(a=6, j_field=dict(foo="bar")) ...
{"foo": "bar"})
self.assertEqual
collection
tests/test_json_field.py
test_char_field_create
JsonFieldTest
10
null
django-extensions/django-extensions
import pytest from django.core.management import CommandError, call_command def test_with_setting_fail(capsys): with pytest.raises(
CommandError, match="INSTALLED_APPZ not found in settings.")
pytest.raises
complex_expr
tests/management/commands/test_print_settings.py
test_with_setting_fail
31
null
django-extensions/django-extensions
import sys from django.contrib.auth.models import Group, Permission from django.test import override_settings from django_extensions.collision_resolvers import ( AppNameCR, AppsOrderCR, BaseCR, PathBasedCR, ) from tests.collisions.models import Group as Group_Col from tests.collisions.models import Nam...
AssertionError, message)
self.assertRaisesRegex
complex_expr
tests/management/commands/shell_plus_tests/test_collision_resolver.py
_assert_bad_resolver
CRTestCase
265
null
django-extensions/django-extensions
import time from django.test import TestCase from django.test.utils import override_settings from django_extensions.logging.filters import RateLimiterFilter from unittest import mock TEST_SUBJECT = "test_subect" class RateLimiterFilterTests(TestCase): def setUp(self): self.rate_limiter_filter = RateLi...
True)
self.assertIs
bool_literal
tests/test_logging_filters.py
test_should_set_cache_key_with_custom_rate_and_return_True
RateLimiterFilterTests
60
null
django-extensions/django-extensions
import json import os import re import tempfile from contextlib import contextmanager from io import StringIO from django.core.management import call_command from django.core.management.base import CommandError from django.test import TestCase def assert_looks_like_dotfile(output): assert output.startswith("digra...
output)
assert_*
variable
tests/management/commands/test_graph_models.py
test_graph_models_json_option_to_stdout
GraphModelsOutputTests
100
null
django-extensions/django-extensions
import os from unittest import mock import logging import importlib from django.core.management import ( call_command, find_commands, load_command_class, BaseCommand, ) from django.test import TestCase from io import StringIO from django_extensions.management.modelviz import use_model, generate_graph_...
1)
self.assertEqual
numeric_literal
tests/test_management_command.py
test_error_logging
CommandTest
70
null
django-extensions/django-extensions
import sys from django.contrib.auth.models import Group, Permission from django.test import override_settings from django_extensions.collision_resolvers import ( AppNameCR, AppsOrderCR, BaseCR, PathBasedCR, ) from tests.collisions.models import Group as Group_Col from tests.collisions.models import Nam...
name_col)
assert_*
variable
tests/management/commands/shell_plus_tests/test_collision_resolver.py
_assert_models_present_under_names
CRTestCase
89
null
django-extensions/django-extensions
import os from unittest import mock import logging import importlib from django.core.management import ( call_command, find_commands, load_command_class, BaseCommand, ) from django.test import TestCase from io import StringIO from django_extensions.management.modelviz import use_model, generate_graph_...
3)
self.assertEqual
numeric_literal
tests/test_management_command.py
test_merge_model_instances
MergeModelInstancesTests
561
null
django-extensions/django-extensions
from unittest.mock import patch from django.core.exceptions import ValidationError from django.test import TestCase, SimpleTestCase from django_extensions.validators import ( NoControlCharactersValidator, NoWhitespaceValidator, HexValidator, ) class TestHexValidator(SimpleTestCase): def test_custom_m...
"message")
self.assertEqual
string_literal
tests/test_validators.py
test_custom_message_and_code
TestHexValidator
111
null
django-extensions/django-extensions
import os from unittest import mock import logging import importlib from django.core.management import ( call_command, find_commands, load_command_class, BaseCommand, ) from django.test import TestCase from io import StringIO from django_extensions.management.modelviz import use_model, generate_graph_...
2)
self.assertEqual
numeric_literal
tests/test_management_command.py
test_merge_model_instances
MergeModelInstancesTests
567
null
django-extensions/django-extensions
from unittest import mock from django.db import models from django.test import TestCase from tests.testapp.models import ( DummyRelationModel, InheritedFromPostWithUniqFieldCompat, PostWithUniqFieldCompat, ReverseModelCompat, SecondDummyRelationModel, ThirdDummyRelationModel, ) from django_ext...
6)
self.assertEqual
numeric_literal
tests/db/fields/test_uniq_field_mixin_compat.py
test__get_fields_returns_correct_model
UniqFieldMixinCompatTestCase
104
null
django-extensions/django-extensions
from importlib import import_module from io import StringIO from django.conf import settings from django.contrib.auth import get_user_model from django.core.management import CommandError, call_command from django.test import TestCase from unittest.mock import patch class PrintUserForSessionExceptionsTests(TestCase)...
CommandError, "malformed session key")
self.assertRaisesRegex
complex_expr
tests/management/commands/test_print_user_for_session.py
test_should_raise_CommandError_if_session_key_contains_exclamination_mark
PrintUserForSessionExceptionsTests
16
null
django-extensions/django-extensions
from io import StringIO from django.conf import settings from django.contrib.sites.models import Site from django.core.management import call_command from django.core.management.base import CommandError from django.test import TestCase from django.test.utils import override_settings from unittest.mock import patch c...
m_stdout.getvalue())
self.assertIn
func_call
tests/management/commands/test_set_default_site.py
test_should_print_Nothing_to_update
SetDefaultSiteTests
52
null
django-extensions/django-extensions
import pytest from django.db import migrations, models from django.db.migrations.writer import MigrationWriter from django.test import TestCase from django.utils.encoding import force_bytes import django_extensions # noqa from django_extensions.db.fields import AutoSlugField from .testapp.models import ( ChildS...
"bar")
self.assertEqual
string_literal
tests/test_autoslug_fields.py
test_update_slug
AutoSlugFieldTest
78
null
django-extensions/django-extensions
from unittest.mock import Mock from django.test import RequestFactory, TestCase from factory import Iterator from django_extensions.admin.filter import NotNullFieldListFilter, NullFieldListFilter from .testapp.factories import SecretFactory from .testapp.models import Secret class NullFieldListFilterTests(BaseField...
result)
self.assertCountEqual
variable
tests/test_admin_filter.py
test_should_not_filter_qs_if_all_lookup_selected
NullFieldListFilterTests
39
null
django-extensions/django-extensions
import os from unittest import mock import logging import importlib from django.core.management import ( call_command, find_commands, load_command_class, BaseCommand, ) from django.test import TestCase from io import StringIO from django_extensions.management.modelviz import use_model, generate_graph_...
Exception)
self.assertRaises
variable
tests/test_management_command.py
test_error_logging
CommandTest
68
null
django-extensions/django-extensions
from django.core import mail from django.core.management import call_command from django.test import TestCase from django.test.utils import override_settings from io import StringIO from unittest.mock import patch class EmailNotificationCommandTests(TestCase): @override_settings(ADMINS=[]) @patch("sys.stdout...
m_stdout.getvalue())
self.assertIn
func_call
tests/management/test_email_notifications.py
test_should_print_that_no_email_recipients_available
EmailNotificationCommandTests
21
null
django-extensions/django-extensions
from django.test import TestCase from django_extensions.db.fields.json import dumps, loads, JSONField, JSONDict, JSONList from .testapp.models import JSONFieldTestModel class JsonFieldTest(TestCase): def test_default_mutable(self): j1 = JSONFieldTestModel.objects.create(a=1) self.assertEqual(j1.j_...
j2.j_field)
self.assertIsNot
complex_expr
tests/test_json_field.py
test_default_mutable
JsonFieldTest
40
null
django-extensions/django-extensions
from io import StringIO from django.conf import settings from django.contrib.sites.models import Site from django.core.management import call_command from django.core.management.base import CommandError from django.test import TestCase from django.test.utils import override_settings from unittest.mock import patch c...
"example.com")
self.assertEqual
string_literal
tests/management/commands/test_set_default_site.py
test_should_set_name_only
SetDefaultSiteTests
93
null
django-extensions/django-extensions
from django.test import TestCase from django_extensions.db.fields.json import dumps, loads, JSONField, JSONDict, JSONList from .testapp.models import JSONFieldTestModel class JsonFieldTest(TestCase): def test_get_default(self): j_field = JSONField() value = j_field.get_default() self.asser...
[{}])
self.assertEqual
collection
tests/test_json_field.py
test_get_default
JsonFieldTest
60
null
django-extensions/django-extensions
import pytest from django.db import migrations, models from django.db.migrations.writer import MigrationWriter from django.test import TestCase from django.utils.encoding import force_bytes import django_extensions # noqa from django_extensions.db.fields import AutoSlugField from .testapp.models import ( ChildS...
"-3")
self.assertEqual
string_literal
tests/test_autoslug_fields.py
test_empty_slug_source
AutoSlugFieldTest
102
null
django-extensions/django-extensions
import sys from django.contrib.auth.models import Group, Permission from django.test import override_settings from django_extensions.collision_resolvers import ( AppNameCR, AppsOrderCR, BaseCR, PathBasedCR, ) from tests.collisions.models import Group as Group_Col from tests.collisions.models import Nam...
group)
assert_*
variable
tests/management/commands/shell_plus_tests/test_collision_resolver.py
_assert_models_present_under_names
CRTestCase
86
null
django-extensions/django-extensions
import importlib.util import os from io import StringIO from django.core.management import CommandError, call_command from django.test import TestCase from django.test.utils import override_settings from unittest import mock class ResetDbSqlite3Tests(TestCase): @mock.patch("sys.stdout", new_callable=StringIO) ...
m_stdout.getvalue())
self.assertEqual
func_call
tests/management/commands/test_reset_db.py
test_should_cancel_reset_db_if_input_is_different_than_yes
ResetDbSqlite3Tests
68
null
django-extensions/django-extensions
from io import StringIO from django.core.management import CommandError, call_command from django.test import TestCase from django.test.utils import override_settings from unittest.mock import patch MYSQL_DATABASE_SETTINGS = { "ENGINE": "django.db.backends.mysql", "NAME": "dbatabase", "USER": "foo", ...
m_stdout.getvalue())
self.assertEqual
func_call
tests/management/commands/test_sqlcreate.py
test_should_print_SQL_create_database_statement_for_mysql
SqlCreateTests
71
null
django-extensions/django-extensions
import sys from io import StringIO import django from django.contrib.auth.models import Permission from django.core.management import call_command from django.db import models from django.test import TestCase class UpdatePermissionsTests(TestCase): def setUp(self): class PermModel(models.Model): ...
out.getvalue())
self.assertIn
func_call
tests/management/commands/test_update_permissions.py
test_works
UpdatePermissionsTests
36
null
django-extensions/django-extensions
from io import StringIO from django.conf import settings from django.contrib.sites.models import Site from django.core.management import call_command from django.core.management.base import CommandError from django.test import TestCase from django.test.utils import override_settings from unittest.mock import patch c...
"foo")
self.assertEqual
string_literal
tests/management/commands/test_set_default_site.py
test_should_set_custom_nameif_system_fqdn_return_domain_and_name_is_provided
SetDefaultSiteTests
78
null
django-extensions/django-extensions
from django.test import SimpleTestCase from django_extensions.management.modelviz import generate_graph_data, ON_DELETE_COLORS class ModelVizTests(SimpleTestCase): def test_render_unicode_field_label(self): app_labels = ["django_extensions"] data = generate_graph_data(app_labels, verbose_names=Tru...
fields)
self.assertEqual
variable
tests/management/test_modelviz.py
test_render_unicode_field_label
ModelVizTests
26
null
django-extensions/django-extensions
import time from django.test import TestCase from .testapp.models import TimestampedTestModel class ModifiedFieldTest(TestCase): def test_update(self): t = TimestampedTestModel.objects.create() modified = t.modified time.sleep(1) t.save() self.assertNotEqual(modified,
t.modified)
self.assertNotEqual
complex_expr
tests/test_timestamped_model.py
test_update
ModifiedFieldTest
15
null
django-extensions/django-extensions
import sys from django.contrib.auth.models import Group, Permission from django.test import override_settings from django_extensions.collision_resolvers import ( AppNameCR, AppsOrderCR, BaseCR, PathBasedCR, ) from tests.collisions.models import Group as Group_Col from tests.collisions.models import Nam...
TypeError, exception_msg)
self.assertRaisesRegex
complex_expr
tests/management/commands/shell_plus_tests/test_collision_resolver.py
test_installed_apps_no_resolve_conflicts_function
CRTestCase
306
null
django-extensions/django-extensions
from django.template import Context, Template, TemplateSyntaxError from django.test import TestCase class HighlightTagExceptionTests(TestCase): def setUp(self): self.ctx = Context() def test_should_raise_TemplateSyntaxError(self): content = """{% load highlighting %} {% highlight %} {% endhig...
TemplateSyntaxError, "'highlight' statement requires an argument")
self.assertRaisesRegex
complex_expr
tests/templatetags/test_highlighting.py
test_should_raise_TemplateSyntaxError
HighlightTagExceptionTests
16
null
django-extensions/django-extensions
from typing import Optional, Set # noqa from django.conf import settings from django.test.utils import override_settings from tests.management.commands.shell_plus_tests.test_utils import ( AutomaticShellPlusImportsTestCase, ) from tests.test_module_in_project_dir import FourthDerivedClass from tests.testapp.deri...
fourth or set())
assert_*
func_call
tests/management/commands/shell_plus_tests/test_import_subclasses.py
assert_imports
ImportSubclassesTestCase
154
null
django-extensions/django-extensions
from unittest import mock from django.db import models from django.test import TestCase from tests.testapp.models import ( DummyRelationModel, InheritedFromPostWithUniqFieldCompat, PostWithUniqFieldCompat, ReverseModelCompat, SecondDummyRelationModel, ThirdDummyRelationModel, ) from django_ext...
9)
self.assertEqual
numeric_literal
tests/db/fields/test_uniq_field_mixin_compat.py
test__get_fields_returns_correct_fields
UniqFieldMixinCompatTestCase
78
null
django-extensions/django-extensions
import pytest from django.db import migrations, models from django.db.migrations.writer import MigrationWriter from django.test import TestCase from django.utils.encoding import force_bytes import django_extensions # noqa from django_extensions.db.fields import AutoSlugField from .testapp.models import ( ChildS...
"test")
self.assertEqual
string_literal
tests/test_autoslug_fields.py
test_precedence_custom_slug_function
AutoSlugFieldTest
231
null
django-extensions/django-extensions
import json import os import re import tempfile from contextlib import contextmanager from io import StringIO from django.core.management import call_command from django.core.management.base import CommandError from django.test import TestCase def assert_looks_like_dotfile(output): assert output.startswith("digra...
foutput)
assert_*
variable
tests/management/commands/test_graph_models.py
test_graph_models_dot_option_to_file
GraphModelsOutputTests
63
null
django-extensions/django-extensions
from io import StringIO from django.test import TestCase from django.db import models from django.core.management import CommandError, call_command class DescribeFormTests(TestCase): def setUp(self): self.out = StringIO() class BaseModel(models.Model): title = models.CharField(max_le...
self.out.getvalue())
self.assertIn
func_call
tests/management/commands/test_describe_form.py
test_should_print_form_definition_for_TestModel
DescribeFormTests
48
null
django-extensions/django-extensions
import os from unittest import mock import logging import importlib from django.core.management import ( call_command, find_commands, load_command_class, BaseCommand, ) from django.test import TestCase from io import StringIO from django_extensions.management.modelviz import use_model, generate_graph_...
4)
self.assertEqual
numeric_literal
tests/test_management_command.py
test_merge_model_instances
MergeModelInstancesTests
557
null
django-extensions/django-extensions
from importlib import import_module from io import StringIO from django.conf import settings from django.contrib.auth import get_user_model from django.core.management import CommandError, call_command from django.test import TestCase from unittest.mock import patch class PrintUserForSessionTests(TestCase): def...
m_stdout.getvalue())
self.assertIn
func_call
tests/management/commands/test_print_user_for_session.py
test_should_print_Session_Key_does_not_exist_or_expired
PrintUserForSessionTests
30
null
django-extensions/django-extensions
from io import StringIO from django.core.management import CommandError, call_command from django.test import TestCase from django.test.utils import override_settings from unittest import mock class ResetSchemaTests(TestCase): @mock.patch("sys.stdout", new_callable=StringIO) @mock.patch("django_extensions.m...
m_stdout.getvalue())
self.assertEqual
func_call
tests/management/commands/test_reset_schema.py
test_should_cancel_reset_schema_and_print_info_if_input_is_different_than_yes
ResetSchemaTests
78
null
django-extensions/django-extensions
from django.test import TestCase from django.utils.text import Truncator from django_extensions.admin import widgets from .testapp import models class ForeignKeySearchInputTestCase(TestCase): def test_widget_works(self): name = models.Name.objects.create(name="Name") person = models.Person.object...
label)
self.assertEqual
variable
tests/test_admin_widgets.py
test_widget_works
ForeignKeySearchInputTestCase
28
null
django-extensions/django-extensions
import string import pytest from django.test import TestCase from .testapp.models import ( RandomCharTestModel, RandomCharTestModelUnique, RandomCharTestModelLowercase, ) from .testapp.models import ( RandomCharTestModelUppercase, RandomCharTestModelAlpha, RandomCharTestModelDigits, ) from .te...
"aaa"
assert
string_literal
tests/test_randomchar_field.py
testRandomCharTestModelDuplicate
RandomCharFieldTest
88
null
django-extensions/django-extensions
import unittest from unittest.mock import Mock from django_extensions.management.shells import import_items class TestImportItems(unittest.TestCase): def setUp(self): self.style = Mock() self.style.ERROR = Mock(return_value="ERROR") self.style.SQL_COLTYPE = Mock(return_value="SQL_COLTYPE") ...
"sys")
self.assertEqual
string_literal
tests/management/commands/shell_plus_tests/test_shells.py
test_simple_import
TestImportItems
15
null
django-extensions/django-extensions
import fnmatch import os import shutil from io import StringIO from django.core.management import call_command from django.test import TestCase class CleanPycTests(TestCase): def setUp(self): self.project_root = os.path.join("tests", "testapp") self._settings = os.environ.get("DJANGO_SETTINGS_MODU...
0)
self.assertEqual
numeric_literal
tests/test_clean_pyc.py
test_removes_pyc_files
CleanPycTests
35
null
django-extensions/django-extensions
from unittest import mock import pytest from io import StringIO from django.conf import settings from django.apps import apps from django.test import TestCase from django_extensions.management.commands.sqldiff import ( SqliteSQLDiff, Command, MySQLDiff, PostgresqlSQLDiff, ) from tests.testapp.models i...
[("common_field", "uniq_field")])
self.assertEqual
collection
tests/test_sqldiff.py
test_get_unique_together
SqlDiffTests
114
null
django-extensions/django-extensions
from django.test import TestCase from django.utils.text import Truncator from django_extensions.admin import widgets from .testapp import models class ForeignKeySearchInputTestCase(TestCase): def test_widget_works(self): name = models.Name.objects.create(name="Name") person = models.Person.object...
widget.media._js)
self.assertListEqual
complex_expr
tests/test_admin_widgets.py
test_widget_works
ForeignKeySearchInputTestCase
38
null
django-extensions/django-extensions
from unittest import mock from django.db import models from django.test import TestCase from tests.testapp.models import ( DummyRelationModel, InheritedFromPostWithUniqField, PostWithUniqField, ReverseModel, SecondDummyRelationModel, ThirdDummyRelationModel, ) from django_extensions.db.fields ...
field)
assert_*
variable
tests/db/fields/test_uniq_field_mixin.py
test_find_unique
UniqFieldMixinTestCase
157
null