[issue1414] Fix for refleak tests

Guido van Rossum report at bugs.python.org
Mon Nov 12 20:47:38 CET 2007


Guido van Rossum added the comment:

If that makes the test pass with and without -R::, go for it!

On Nov 12, 2007 11:14 AM, Christian Heimes <report at bugs.python.org> wrote:
>
> Christian Heimes added the comment:
>
> How do you like;
>
> class TestPkg(unittest.TestCase):
>
>     def setUp(self):
>         self.root = None
>         self.syspath = list(sys.path)
>         self.sysmodules = sys.modules.copy()
>
>     def tearDown(self):
>         sys.path[:] = self.syspath
>         sys.modules.clear()
>         sys.modules.update(self.sysmodules)
>         del self.sysmodules
>         cleanout(self.root)
>
> Or I could use the paranoid approach: create set from sys.modules.keys()
> in setUp + tearDown and remove the items that are in the second set but
> not in the first set.
>
>
> __________________________________
> Tracker <report at bugs.python.org>
> <http://bugs.python.org/issue1414>
> __________________________________
>

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1414>
__________________________________


More information about the Python-bugs-list mailing list