Commit 6738b115 authored by Yury Selivanov's avatar Yury Selivanov

Issue 24208: Fix tests -- don't create a tempdir in __init__.

parent de12b79c
...@@ -288,9 +288,7 @@ class GetSourceBase(unittest.TestCase): ...@@ -288,9 +288,7 @@ class GetSourceBase(unittest.TestCase):
# Subclasses must override. # Subclasses must override.
fodderModule = None fodderModule = None
def __init__(self, *args, **kwargs): def setUp(self):
unittest.TestCase.__init__(self, *args, **kwargs)
with open(inspect.getsourcefile(self.fodderModule)) as fp: with open(inspect.getsourcefile(self.fodderModule)) as fp:
self.source = fp.read() self.source = fp.read()
...@@ -571,7 +569,7 @@ class TestBuggyCases(GetSourceBase): ...@@ -571,7 +569,7 @@ class TestBuggyCases(GetSourceBase):
self.assertSourceEqual(mod2.ClassWithMethod.method, 118, 119) self.assertSourceEqual(mod2.ClassWithMethod.method, 118, 119)
class TestNoEOL(GetSourceBase): class TestNoEOL(GetSourceBase):
def __init__(self, *args, **kwargs): def setUp(self):
self.tempdir = TESTFN + '_dir' self.tempdir = TESTFN + '_dir'
os.mkdir(self.tempdir) os.mkdir(self.tempdir)
with open(os.path.join(self.tempdir, with open(os.path.join(self.tempdir,
...@@ -580,7 +578,7 @@ class TestNoEOL(GetSourceBase): ...@@ -580,7 +578,7 @@ class TestNoEOL(GetSourceBase):
with DirsOnSysPath(self.tempdir): with DirsOnSysPath(self.tempdir):
import inspect_fodder3 as mod3 import inspect_fodder3 as mod3
self.fodderModule = mod3 self.fodderModule = mod3
GetSourceBase.__init__(self, *args, **kwargs) super().setUp()
def tearDown(self): def tearDown(self):
shutil.rmtree(self.tempdir) shutil.rmtree(self.tempdir)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment