[Piglit] [PATCH 38/44] unittests/opengl_tests.py: stop mock leakage
baker.dylan.c at gmail.com
baker.dylan.c at gmail.com
Wed Jan 27 16:06:46 PST 2016
From: Dylan Baker <baker.dylan.c at gmail.com>
For some reason in python 3 (all versions) some of the mock patchers in
this opengl test leak out into other modules. This doesn't happen in
python 2. I'm not sure why this fixes the issue, but it does.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
unittests/opengl_tests.py | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/unittests/opengl_tests.py b/unittests/opengl_tests.py
index 3131bdd..5fb75fa 100644
--- a/unittests/opengl_tests.py
+++ b/unittests/opengl_tests.py
@@ -179,14 +179,13 @@ class TestWflInfo_WAFFLEINFO_GL_ERROR(object):
"""Test class for WflInfo when "WFLINFO_GL_ERROR" is returned."""
__patchers = []
- def setup(self):
+ @classmethod
+ def setup_class(cls):
"""Setup each instance, patching necissary bits."""
- self._test = opengl.WflInfo()
- self.__patchers.append(mock.patch.dict(
+ cls._test = opengl.WflInfo()
+ cls.__patchers.append(mock.patch.dict(
'framework.test.opengl.OPTIONS.env',
{'PIGLIT_PLATFORM': 'foo'}))
- self.__patchers.append(mock.patch(
- 'framework.test.opengl.WflInfo._WflInfo__shared_state', {}))
rv = textwrap.dedent("""\
Waffle platform: glx
@@ -199,17 +198,26 @@ class TestWflInfo_WAFFLEINFO_GL_ERROR(object):
OpenGL extensions: WFLINFO_GL_ERROR
""").encode('utf-8')
- self.__patchers.append(mock.patch(
+ cls.__patchers.append(mock.patch(
'framework.test.opengl.subprocess.check_output',
mock.Mock(return_value=rv)))
- for f in self.__patchers:
+ for f in cls.__patchers:
f.start()
- def teardown(self):
- for p in self.__patchers:
+ @classmethod
+ def teardown_class(cls):
+ for p in cls.__patchers:
p.stop()
+ def setup(self):
+ self.__state = mock.patch(
+ 'framework.test.opengl.WflInfo._WflInfo__shared_state', {})
+ self.__state.start()
+
+ def teardown(self):
+ self.__state.stop()
+
def test_gl_version(self):
"""test.opengl.WflInfo.gl_version: handles WFLINFO_GL_ERROR correctly"""
nt.eq_(None, self._test.gl_version)
--
2.7.0
More information about the Piglit
mailing list