mirror of
https://github.com/python/cpython.git
synced 2025-08-09 19:38:42 +00:00
[3.12] gh-71339: Add additional assertion methods in test.support (GH-128707) (GH-128815) (GH-129059)
Add a mix-in class ExtraAssertions containing the following methods: * assertHasAttr() and assertNotHasAttr() * assertIsSubclass() and assertNotIsSubclass() * assertStartsWith() and assertNotStartsWith() * assertEndsWith() and assertNotEndsWith() (cherry picked from commitc6a566e47b
) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> (cherry picked from commit06cad77a5b
)
This commit is contained in:
parent
7f68e7bf2a
commit
032058cb62
6 changed files with 68 additions and 49 deletions
|
@ -25,6 +25,7 @@ from test.support import (captured_stdout, captured_stderr,
|
|||
requires_resource, copy_python_src_ignore)
|
||||
from test.support.os_helper import (can_symlink, EnvironmentVarGuard, rmtree,
|
||||
TESTFN, FakePath)
|
||||
from test.support.testcase import ExtraAssertions
|
||||
import unittest
|
||||
import venv
|
||||
from unittest.mock import patch, Mock
|
||||
|
@ -58,7 +59,7 @@ def check_output(cmd, encoding=None):
|
|||
p.returncode, cmd, out, err)
|
||||
return out, err
|
||||
|
||||
class BaseTest(unittest.TestCase):
|
||||
class BaseTest(unittest.TestCase, ExtraAssertions):
|
||||
"""Base class for venv tests."""
|
||||
maxDiff = 80 * 50
|
||||
|
||||
|
@ -98,10 +99,6 @@ class BaseTest(unittest.TestCase):
|
|||
result = f.read()
|
||||
return result
|
||||
|
||||
def assertEndsWith(self, string, tail):
|
||||
if not string.endswith(tail):
|
||||
self.fail(f"String {string!r} does not end with {tail!r}")
|
||||
|
||||
class BasicTest(BaseTest):
|
||||
"""Test venv module functionality."""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue