diff options
author | Jonas Haag <jonas@lophus.org> | 2017-11-28 20:40:44 +0100 |
---|---|---|
committer | Antoine Pitrou <pitrou@free.fr> | 2017-11-28 20:40:44 +0100 |
commit | 4d193bcc2560b824389e4d98d9d8b9b34e33dbaf (patch) | |
tree | 18a9f541c72092fb0c13c588564d4e7a3a722e8e /Lib/unittest/test/test_loader.py | |
parent | a489599793f9b00ddc2c68e2ce3bce9cbb2c09a2 (diff) | |
download | cpython-git-4d193bcc2560b824389e4d98d9d8b9b34e33dbaf.tar.gz |
bpo-32071: Fix regression and add What's New entry (#4589)
* bpo-32071: Fix an undocumented behaviour regression
* bpo-32071: Add 3.7 release note entry for unittest -k
Diffstat (limited to 'Lib/unittest/test/test_loader.py')
-rw-r--r-- | Lib/unittest/test/test_loader.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/unittest/test/test_loader.py b/Lib/unittest/test/test_loader.py index 15b01863f5..bfd722940b 100644 --- a/Lib/unittest/test/test_loader.py +++ b/Lib/unittest/test/test_loader.py @@ -1253,6 +1253,29 @@ class Test_TestLoader(unittest.TestCase): loader.testNamePatterns = ['*my*'] self.assertEqual(loader.getTestCaseNames(MyTest), []) + # "Return a sorted sequence of method names found within testCaseClass" + # + # If TestLoader.testNamePatterns is set, only tests that match one of these + # patterns should be included. + # + # For backwards compatibility reasons (see bpo-32071), the check may only + # touch a TestCase's attribute if it starts with the test method prefix. + def test_getTestCaseNames__testNamePatterns__attribute_access_regression(self): + class Trap: + def __get__(*ignored): + self.fail('Non-test attribute accessed') + + class MyTest(unittest.TestCase): + def test_1(self): pass + foobar = Trap() + + loader = unittest.TestLoader() + self.assertEqual(loader.getTestCaseNames(MyTest), ['test_1']) + + loader = unittest.TestLoader() + loader.testNamePatterns = [] + self.assertEqual(loader.getTestCaseNames(MyTest), []) + ################################################################ ### /Tests for TestLoader.getTestCaseNames() |