Is this something related to running under coverage? With the failure commit on Travis I built the binary and there are no failures with unittest but the tests fail with coverage. Running 'set.add(0)' under coverage and as normal file generates different error messages. Can you try running with unittest to see if there are any discrepancies? I am adding @nedbat who might have a better explanation.
# Python version
(foo-venv) karthi@ubuntu-s-1vcpu-1gb-blr1-01:~/cpython$ python
Python 3.8.0a1+ (tags/v3.8.0a1-23-g8a03ff2ff4:8a03ff2ff4, Feb 11 2019, 15:51:54)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
# set.add(0) under coverage and as a file
(foo-venv) karthi@ubuntu-s-1vcpu-1gb-blr1-01:~/cpython$ echo "set.add(0)" > foo.py
(foo-venv) karthi@ubuntu-s-1vcpu-1gb-blr1-01:~/cpython$ coverage run foo.py
Traceback (most recent call last):
File "foo.py", line 1, in <module>
set.add(0)
TypeError: descriptor 'add' for 'set' objects doesn't apply to 'int' object
(foo-venv) karthi@ubuntu-s-1vcpu-1gb-blr1-01:~/cpython$ python foo.py
Traceback (most recent call last):
File "foo.py", line 1, in <module>
set.add(0)
TypeError: descriptor 'add' requires a 'set' object but received a 'int'
# Running the reported case will fail while running under coverage
(foo-venv) karthi@ubuntu-s-1vcpu-1gb-blr1-01:~/cpython$ python -m unittest discover --start-directory=/tmp/suggest --pattern=*.py
..
----------------------------------------------------------------------
Ran 2 tests in 0.002s
OK
(foo-venv) karthi@ubuntu-s-1vcpu-1gb-blr1-01:~/cpython$ coverage run -m unittest discover --start-directory=/tmp/suggest --pattern=*.py
FF
======================================================================
FAIL: test_assertRaisesRegex (foo.FooTest)
----------------------------------------------------------------------
TypeError: descriptor 'add' for 'set' objects doesn't apply to 'int' object
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/suggest/foo.py", line 8, in test_assertRaisesRegex
self.assertRaisesRegex(TypeError, DESCRIPT_REQUIRES_TYPE_RE, set.add, 0)
AssertionError: "descriptor '\w+' requires a 'set' object but received a 'int'" does not match "descriptor 'add' for 'set' objects doesn't apply to 'int' object"
======================================================================
FAIL: test_assertRaisesRegex_contextman (foo.FooTest)
----------------------------------------------------------------------
TypeError: descriptor 'add' for 'set' objects doesn't apply to 'int' object
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/suggest/foo.py", line 12, in test_assertRaisesRegex_contextman
set.add(0)
AssertionError: "descriptor '\w+' requires a 'set' object but received a 'int'" does not match "descriptor 'add' for 'set' objects doesn't apply to 'int' object"
----------------------------------------------------------------------
Ran 2 tests in 0.003s
FAILED (failures=2)
# Executed test
(foo-venv) karthi@ubuntu-s-1vcpu-1gb-blr1-01:~/cpython$ cat /tmp/suggest/foo.py
import unittest
DESCRIPT_REQUIRES_TYPE_RE = r"descriptor '\w+' requires a 'set' object but received a 'int'"
class FooTest(unittest.TestCase):
def test_assertRaisesRegex(self):
self.assertRaisesRegex(TypeError, DESCRIPT_REQUIRES_TYPE_RE, set.add, 0)
def test_assertRaisesRegex_contextman(self):
with self.assertRaisesRegex(TypeError, DESCRIPT_REQUIRES_TYPE_RE):
set.add(0)
if __name__ == "__main__":
unittest.main() |