mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Fix abc error messages (#5140)
Co-authored-by: Jeong, YunWon <jeong@youknowone.org>
This commit is contained in:
12
Lib/test/test_abc.py
vendored
12
Lib/test/test_abc.py
vendored
@@ -149,8 +149,6 @@ def test_factory(abc_ABCMeta, abc_get_cache_token):
|
||||
self.assertEqual(D.foo(), 4)
|
||||
self.assertEqual(D().foo(), 4)
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_object_new_with_one_abstractmethod(self):
|
||||
class C(metaclass=abc_ABCMeta):
|
||||
@abc.abstractmethod
|
||||
@@ -159,8 +157,6 @@ def test_factory(abc_ABCMeta, abc_get_cache_token):
|
||||
msg = r"class C without an implementation for abstract method 'method_one'"
|
||||
self.assertRaisesRegex(TypeError, msg, C)
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_object_new_with_many_abstractmethods(self):
|
||||
class C(metaclass=abc_ABCMeta):
|
||||
@abc.abstractmethod
|
||||
@@ -526,8 +522,6 @@ def test_factory(abc_ABCMeta, abc_get_cache_token):
|
||||
self.assertEqual(A.__abstractmethods__, set())
|
||||
A()
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_update_new_abstractmethods(self):
|
||||
class A(metaclass=abc_ABCMeta):
|
||||
@abc.abstractmethod
|
||||
@@ -544,8 +538,6 @@ def test_factory(abc_ABCMeta, abc_get_cache_token):
|
||||
msg = "class A without an implementation for abstract methods 'bar', 'foo'"
|
||||
self.assertRaisesRegex(TypeError, msg, A)
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_update_implementation(self):
|
||||
class A(metaclass=abc_ABCMeta):
|
||||
@abc.abstractmethod
|
||||
@@ -597,8 +589,6 @@ def test_factory(abc_ABCMeta, abc_get_cache_token):
|
||||
A()
|
||||
self.assertFalse(hasattr(A, '__abstractmethods__'))
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_update_del_implementation(self):
|
||||
class A(metaclass=abc_ABCMeta):
|
||||
@abc.abstractmethod
|
||||
@@ -618,8 +608,6 @@ def test_factory(abc_ABCMeta, abc_get_cache_token):
|
||||
msg = "class B without an implementation for abstract method 'foo'"
|
||||
self.assertRaisesRegex(TypeError, msg, B)
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_update_layered_implementation(self):
|
||||
class A(metaclass=abc_ABCMeta):
|
||||
@abc.abstractmethod
|
||||
|
||||
1
Lib/test/test_dataclasses.py
vendored
1
Lib/test/test_dataclasses.py
vendored
@@ -3676,6 +3676,7 @@ class TestAbstract(unittest.TestCase):
|
||||
self.assertFalse(inspect.isabstract(Date))
|
||||
self.assertGreater(Date(2020,12,25), Date(2020,8,31))
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_maintain_abc(self):
|
||||
class A(abc.ABC):
|
||||
@abc.abstractmethod
|
||||
|
||||
@@ -41,7 +41,7 @@ impl Constructor for PyBaseObject {
|
||||
if let Some(unimplemented_abstract_method_count) = abs_methods.length_opt(vm) {
|
||||
let methods: Vec<PyStrRef> = abs_methods.try_to_value(vm)?;
|
||||
let methods: String =
|
||||
Itertools::intersperse(methods.iter().map(|name| name.as_str()), ", ")
|
||||
Itertools::intersperse(methods.iter().map(|name| name.as_str()), "', '")
|
||||
.collect();
|
||||
|
||||
let unimplemented_abstract_method_count = unimplemented_abstract_method_count?;
|
||||
@@ -51,13 +51,13 @@ impl Constructor for PyBaseObject {
|
||||
0 => {}
|
||||
1 => {
|
||||
return Err(vm.new_type_error(format!(
|
||||
"Can't instantiate abstract class {} with abstract method {}",
|
||||
"class {} without an implementation for abstract method '{}'",
|
||||
name, methods
|
||||
)));
|
||||
}
|
||||
2.. => {
|
||||
return Err(vm.new_type_error(format!(
|
||||
"Can't instantiate abstract class {} with abstract methods {}",
|
||||
"class {} without an implementation for abstract methods '{}'",
|
||||
name, methods
|
||||
)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user