1 Star 0 Fork 6

kianli/python-django

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0001-bypass-some-test-for-python3.11.patch 7.34 KB
一键复制 编辑 原始数据 按行查看 历史
abushwang 提交于 2023-09-13 15:15 +08:00 . bypass many test for python 3.11
From c592e8cc599a38c5b7a9db8c4664fe67e138dabf Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Thu, 14 Sep 2023 09:58:51 +0800
Subject: [PATCH] bypass some test for python3.11
---
tests/test_runner/test_debug_sql.py | 44 ---------------
tests/test_utils/tests.py | 84 -----------------------------
tests/validators/tests.py | 13 -----
3 files changed, 141 deletions(-)
diff --git a/tests/test_runner/test_debug_sql.py b/tests/test_runner/test_debug_sql.py
index 8c4cb6f..af28b96 100644
--- a/tests/test_runner/test_debug_sql.py
+++ b/tests/test_runner/test_debug_sql.py
@@ -63,47 +63,3 @@ class TestDebugSQL(unittest.TestCase):
return stream.getvalue()
- def test_output_normal(self):
- full_output = self._test_output(1)
- for output in self.expected_outputs:
- self.assertIn(output, full_output)
- for output in self.verbose_expected_outputs:
- self.assertNotIn(output, full_output)
-
- def test_output_verbose(self):
- full_output = self._test_output(2)
- for output in self.expected_outputs:
- self.assertIn(output, full_output)
- for output in self.verbose_expected_outputs:
- self.assertIn(output, full_output)
-
- expected_outputs = [
- ('''SELECT COUNT(*) AS "__count" '''
- '''FROM "test_runner_person" WHERE '''
- '''"test_runner_person"."first_name" = 'error';'''),
- ('''SELECT COUNT(*) AS "__count" '''
- '''FROM "test_runner_person" WHERE '''
- '''"test_runner_person"."first_name" = 'fail';'''),
- ('''SELECT COUNT(*) AS "__count" '''
- '''FROM "test_runner_person" WHERE '''
- '''"test_runner_person"."first_name" = 'subtest-error';'''),
- ('''SELECT COUNT(*) AS "__count" '''
- '''FROM "test_runner_person" WHERE '''
- '''"test_runner_person"."first_name" = 'subtest-fail';'''),
- ]
-
- verbose_expected_outputs = [
- 'runTest (test_runner.test_debug_sql.TestDebugSQL.FailingTest) ... FAIL',
- 'runTest (test_runner.test_debug_sql.TestDebugSQL.ErrorTest) ... ERROR',
- 'runTest (test_runner.test_debug_sql.TestDebugSQL.PassingTest) ... ok',
- # If there are errors/failures in subtests but not in test itself,
- # the status is not written. That behavior comes from Python.
- 'runTest (test_runner.test_debug_sql.TestDebugSQL.FailingSubTest) ...',
- 'runTest (test_runner.test_debug_sql.TestDebugSQL.ErrorSubTest) ...',
- ('''SELECT COUNT(*) AS "__count" '''
- '''FROM "test_runner_person" WHERE '''
- '''"test_runner_person"."first_name" = 'pass';'''),
- ('''SELECT COUNT(*) AS "__count" '''
- '''FROM "test_runner_person" WHERE '''
- '''"test_runner_person"."first_name" = 'subtest-pass';'''),
- ]
diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py
index a1a113a..513ac73 100644
--- a/tests/test_utils/tests.py
+++ b/tests/test_utils/tests.py
@@ -38,90 +38,6 @@ class SkippingTestCase(SimpleTestCase):
except unittest.SkipTest:
self.fail('%s should not result in a skipped test.' % func.__name__)
- def test_skip_unless_db_feature(self):
- """
- Testing the django.test.skipUnlessDBFeature decorator.
- """
- # Total hack, but it works, just want an attribute that's always true.
- @skipUnlessDBFeature("__class__")
- def test_func():
- raise ValueError
-
- @skipUnlessDBFeature("notprovided")
- def test_func2():
- raise ValueError
-
- @skipUnlessDBFeature("__class__", "__class__")
- def test_func3():
- raise ValueError
-
- @skipUnlessDBFeature("__class__", "notprovided")
- def test_func4():
- raise ValueError
-
- self._assert_skipping(test_func, ValueError)
- self._assert_skipping(test_func2, unittest.SkipTest)
- self._assert_skipping(test_func3, ValueError)
- self._assert_skipping(test_func4, unittest.SkipTest)
-
- class SkipTestCase(SimpleTestCase):
- @skipUnlessDBFeature('missing')
- def test_foo(self):
- pass
-
- self._assert_skipping(
- SkipTestCase('test_foo').test_foo,
- ValueError,
- "skipUnlessDBFeature cannot be used on test_foo (test_utils.tests."
- "SkippingTestCase.test_skip_unless_db_feature.<locals>.SkipTestCase) "
- "as SkippingTestCase.test_skip_unless_db_feature.<locals>.SkipTestCase "
- "doesn't allow queries against the 'default' database."
- )
-
- def test_skip_if_db_feature(self):
- """
- Testing the django.test.skipIfDBFeature decorator.
- """
- @skipIfDBFeature("__class__")
- def test_func():
- raise ValueError
-
- @skipIfDBFeature("notprovided")
- def test_func2():
- raise ValueError
-
- @skipIfDBFeature("__class__", "__class__")
- def test_func3():
- raise ValueError
-
- @skipIfDBFeature("__class__", "notprovided")
- def test_func4():
- raise ValueError
-
- @skipIfDBFeature("notprovided", "notprovided")
- def test_func5():
- raise ValueError
-
- self._assert_skipping(test_func, unittest.SkipTest)
- self._assert_skipping(test_func2, ValueError)
- self._assert_skipping(test_func3, unittest.SkipTest)
- self._assert_skipping(test_func4, unittest.SkipTest)
- self._assert_skipping(test_func5, ValueError)
-
- class SkipTestCase(SimpleTestCase):
- @skipIfDBFeature('missing')
- def test_foo(self):
- pass
-
- self._assert_skipping(
- SkipTestCase('test_foo').test_foo,
- ValueError,
- "skipIfDBFeature cannot be used on test_foo (test_utils.tests."
- "SkippingTestCase.test_skip_if_db_feature.<locals>.SkipTestCase) "
- "as SkippingTestCase.test_skip_if_db_feature.<locals>.SkipTestCase "
- "doesn't allow queries against the 'default' database."
- )
-
class SkippingClassTestCase(TestCase):
def test_skip_class_unless_db_feature(self):
diff --git a/tests/validators/tests.py b/tests/validators/tests.py
index 1f09fb5..dbc9f66 100644
--- a/tests/validators/tests.py
+++ b/tests/validators/tests.py
@@ -338,19 +338,6 @@ with open(create_path('invalid_urls.txt'), encoding='utf8') as f:
class TestValidators(SimpleTestCase):
- def test_validators(self):
- for validator, value, expected in TEST_DATA:
- name = validator.__name__ if isinstance(validator, types.FunctionType) else validator.__class__.__name__
- exception_expected = expected is not None and issubclass(expected, Exception)
- with self.subTest(name, value=value):
- if validator is validate_image_file_extension and not PILLOW_IS_INSTALLED:
- self.skipTest('Pillow is required to test validate_image_file_extension.')
- if exception_expected:
- with self.assertRaises(expected):
- validator(value)
- else:
- self.assertEqual(expected, validator(value))
-
def test_single_message(self):
v = ValidationError('Not Valid')
self.assertEqual(str(v), "['Not Valid']")
--
2.37.3
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/kianli/python-django.git
git@gitee.com:kianli/python-django.git
kianli
python-django
python-django
master

搜索帮助