diff options
author | E. M. Bray <erik.m.bray@gmail.com> | 2018-10-04 04:42:27 +0200 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2018-10-03 19:42:27 -0700 |
commit | a611f60dc73d9df64fd8ebcec1daf9f7827e29db (patch) | |
tree | 21b7198919583a54a5d20635a0f315a7e4ba791a /test_six.py | |
parent | b4eb51609fac1ae232b4222fccd54c7ddfc243ab (diff) | |
download | six-git-a611f60dc73d9df64fd8ebcec1daf9f7827e29db.tar.gz |
Make add_metaclass copy __qualname__ from the original class. (#260)
Fixes #259.
Diffstat (limited to 'test_six.py')
-rw-r--r-- | test_six.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test_six.py b/test_six.py index 980cdf3..897e232 100644 --- a/test_six.py +++ b/test_six.py @@ -875,6 +875,26 @@ def test_add_metaclass(): assert type(MySlotsWeakref) is Meta +@py.test.mark.skipif("sys.version_info[:2] < (3, 3)") +def test_add_metaclass_nested(): + # Regression test for https://github.com/benjaminp/six/issues/259 + class Meta(type): + pass + + class A: + class B: pass + + expected = 'test_add_metaclass_nested.<locals>.A.B' + + assert A.B.__qualname__ == expected + + class A: + @six.add_metaclass(Meta) + class B: pass + + assert A.B.__qualname__ == expected + + @py.test.mark.skipif("sys.version_info[:2] < (2, 7) or sys.version_info[:2] in ((3, 0), (3, 1))") def test_assertCountEqual(): class TestAssertCountEqual(unittest.TestCase): |