-
-
Notifications
You must be signed in to change notification settings - Fork 32k
test_sqlite3.test_userfunctions redefines test_func_return_too_large_int() method #105557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Oh, that's unfortunate. Thanks for the report, Victor! |
What's unfortunate is that unittest has no metaclass using a prepare method with a custom dict type which detects such bug. |
test_func_return_too_large_int() was defined twice. Keep only the redefined method, as that also checks the tracebacks.
+1 That would be a useful feature. |
Prototype to detect such bug: import inspect
import warnings
class MyDict(dict):
def __init__(self, class_name):
self.class_name = class_name
def __setitem__(self, name, value):
# TestLoader.testMethodPrefix = 'test'
if name.startswith('test'):
try:
old_value = self[name]
except KeyError:
pass
else:
if inspect.isfunction(old_value):
warnings.warn(f"BUG: {self.class_name}.{name}() method redefined", stacklevel=2)
dict.__setitem__(self, name, value)
class MyMetaClass(type):
@classmethod
def __prepare__(metacls, class_name, bases, **kwds):
return MyDict(class_name)
class TestCase(metaclass=MyMetaClass):
pass
class Tests(TestCase):
def __init__(self):
self.attr = 1
self.attr = 2
def test_bug(self): # first defintion
pass
def test_bug(self): # second definion
pass
tests = Tests() Output:
|
I created issue #105560 to track this idea. |
test_func_return_too_large_int() was defined twice. Keep only the redefined method, as that also checks the tracebacks.
test_func_return_too_large_int() was defined twice. Keep only the redefined method, as that also checks the tracebacks. (cherry picked from commit b8fa7bd) Co-authored-by: Erlend E. Aasland <[email protected]>
test_func_return_too_large_int() was defined twice. Keep only the redefined method, as that also checks the tracebacks. (cherry picked from commit b8fa7bd) Co-authored-by: Erlend E. Aasland <[email protected]>
…105562) test_func_return_too_large_int() was defined twice. Keep only the redefined method, as that also checks the tracebacks. (cherry picked from commit b8fa7bd) Co-authored-by: Erlend E. Aasland <[email protected]>
…105561) test_func_return_too_large_int() was defined twice. Keep only the redefined method, as that also checks the tracebacks. (cherry picked from commit b8fa7bd) Co-authored-by: Erlend E. Aasland <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
Lib/test/test_sqlite3/test_userfunctions.py defines to methods called test_func_return_too_large_int() in the same class, so the first one is never called.
cc @erlend-aasland
Linked PRs
The text was updated successfully, but these errors were encountered: