Commit eab2a50d authored by Antoine Pitrou's avatar Antoine Pitrou

PEP8-ize test names

parent 8cd8d5e8
...@@ -31,7 +31,7 @@ else: ...@@ -31,7 +31,7 @@ else:
# threads is not done here. # threads is not done here.
# Common functionality. # Common functionality.
class TC(unittest.TestCase): class BaseTestCase(unittest.TestCase):
str_check = re.compile(r"[a-zA-Z0-9_-]{6}$") str_check = re.compile(r"[a-zA-Z0-9_-]{6}$")
...@@ -63,9 +63,8 @@ class TC(unittest.TestCase): ...@@ -63,9 +63,8 @@ class TC(unittest.TestCase):
"random string '%s' does not match /^[a-zA-Z0-9_-]{6}$/" "random string '%s' does not match /^[a-zA-Z0-9_-]{6}$/"
% nbase) % nbase)
test_classes = []
class test_exports(TC): class TestExports(BaseTestCase):
def test_exports(self): def test_exports(self):
# There are no surprising symbols in the tempfile module # There are no surprising symbols in the tempfile module
dict = tempfile.__dict__ dict = tempfile.__dict__
...@@ -92,10 +91,8 @@ class test_exports(TC): ...@@ -92,10 +91,8 @@ class test_exports(TC):
self.assertTrue(len(unexp) == 0, self.assertTrue(len(unexp) == 0,
"unexpected keys: %s" % unexp) "unexpected keys: %s" % unexp)
test_classes.append(test_exports)
class TestRandomNameSequence(BaseTestCase):
class test__RandomNameSequence(TC):
"""Test the internal iterator object _RandomNameSequence.""" """Test the internal iterator object _RandomNameSequence."""
def setUp(self): def setUp(self):
...@@ -159,10 +156,8 @@ class test__RandomNameSequence(TC): ...@@ -159,10 +156,8 @@ class test__RandomNameSequence(TC):
self.assertNotEqual(child_value, parent_value) self.assertNotEqual(child_value, parent_value)
test_classes.append(test__RandomNameSequence)
class test__candidate_tempdir_list(TC): class TestCandidateTempdirList(BaseTestCase):
"""Test the internal function _candidate_tempdir_list.""" """Test the internal function _candidate_tempdir_list."""
def test_nonempty_list(self): def test_nonempty_list(self):
...@@ -201,13 +196,11 @@ class test__candidate_tempdir_list(TC): ...@@ -201,13 +196,11 @@ class test__candidate_tempdir_list(TC):
# Not practical to try to verify the presence of OS-specific # Not practical to try to verify the presence of OS-specific
# paths in this list. # paths in this list.
test_classes.append(test__candidate_tempdir_list)
# We test _get_default_tempdir by testing gettempdir. # We test _get_default_tempdir by testing gettempdir.
class test__get_candidate_names(TC): class TestGetCandidateNames(BaseTestCase):
"""Test the internal function _get_candidate_names.""" """Test the internal function _get_candidate_names."""
def test_retval(self): def test_retval(self):
...@@ -222,10 +215,8 @@ class test__get_candidate_names(TC): ...@@ -222,10 +215,8 @@ class test__get_candidate_names(TC):
self.assertTrue(a is b) self.assertTrue(a is b)
test_classes.append(test__get_candidate_names)
class test__mkstemp_inner(TC): class TestMkstempInner(BaseTestCase):
"""Test the internal function _mkstemp_inner.""" """Test the internal function _mkstemp_inner."""
class mkstemped: class mkstemped:
...@@ -342,10 +333,8 @@ class test__mkstemp_inner(TC): ...@@ -342,10 +333,8 @@ class test__mkstemp_inner(TC):
os.lseek(f.fd, 0, os.SEEK_SET) os.lseek(f.fd, 0, os.SEEK_SET)
self.assertEqual(os.read(f.fd, 20), b"blat") self.assertEqual(os.read(f.fd, 20), b"blat")
test_classes.append(test__mkstemp_inner)
class TestGetTempPrefix(BaseTestCase):
class test_gettempprefix(TC):
"""Test gettempprefix().""" """Test gettempprefix()."""
def test_sane_template(self): def test_sane_template(self):
...@@ -371,10 +360,8 @@ class test_gettempprefix(TC): ...@@ -371,10 +360,8 @@ class test_gettempprefix(TC):
finally: finally:
os.rmdir(d) os.rmdir(d)
test_classes.append(test_gettempprefix)
class test_gettempdir(TC): class TestGetTempDir(BaseTestCase):
"""Test gettempdir().""" """Test gettempdir()."""
def test_directory_exists(self): def test_directory_exists(self):
...@@ -403,10 +390,8 @@ class test_gettempdir(TC): ...@@ -403,10 +390,8 @@ class test_gettempdir(TC):
self.assertTrue(a is b) self.assertTrue(a is b)
test_classes.append(test_gettempdir)
class TestMkstemp(BaseTestCase):
class test_mkstemp(TC):
"""Test mkstemp().""" """Test mkstemp()."""
def do_create(self, dir=None, pre="", suf=""): def do_create(self, dir=None, pre="", suf=""):
...@@ -441,10 +426,8 @@ class test_mkstemp(TC): ...@@ -441,10 +426,8 @@ class test_mkstemp(TC):
finally: finally:
os.rmdir(dir) os.rmdir(dir)
test_classes.append(test_mkstemp)
class test_mkdtemp(TC): class TestMkdtemp(BaseTestCase):
"""Test mkdtemp().""" """Test mkdtemp()."""
def do_create(self, dir=None, pre="", suf=""): def do_create(self, dir=None, pre="", suf=""):
...@@ -505,10 +488,8 @@ class test_mkdtemp(TC): ...@@ -505,10 +488,8 @@ class test_mkdtemp(TC):
finally: finally:
os.rmdir(dir) os.rmdir(dir)
test_classes.append(test_mkdtemp)
class TestMktemp(BaseTestCase):
class test_mktemp(TC):
"""Test mktemp().""" """Test mktemp()."""
# For safety, all use of mktemp must occur in a private directory. # For safety, all use of mktemp must occur in a private directory.
...@@ -564,13 +545,11 @@ class test_mktemp(TC): ...@@ -564,13 +545,11 @@ class test_mktemp(TC):
## self.assertRaises(RuntimeWarning, ## self.assertRaises(RuntimeWarning,
## tempfile.mktemp, dir=self.dir) ## tempfile.mktemp, dir=self.dir)
test_classes.append(test_mktemp)
# We test _TemporaryFileWrapper by testing NamedTemporaryFile. # We test _TemporaryFileWrapper by testing NamedTemporaryFile.
class test_NamedTemporaryFile(TC): class TestNamedTemporaryFile(BaseTestCase):
"""Test NamedTemporaryFile().""" """Test NamedTemporaryFile()."""
def do_create(self, dir=None, pre="", suf="", delete=True): def do_create(self, dir=None, pre="", suf="", delete=True):
...@@ -645,9 +624,8 @@ class test_NamedTemporaryFile(TC): ...@@ -645,9 +624,8 @@ class test_NamedTemporaryFile(TC):
# How to test the mode and bufsize parameters? # How to test the mode and bufsize parameters?
test_classes.append(test_NamedTemporaryFile)
class test_SpooledTemporaryFile(TC): class TestSpooledTemporaryFile(BaseTestCase):
"""Test SpooledTemporaryFile().""" """Test SpooledTemporaryFile()."""
def do_create(self, max_size=0, dir=None, pre="", suf=""): def do_create(self, max_size=0, dir=None, pre="", suf=""):
...@@ -859,10 +837,10 @@ class test_SpooledTemporaryFile(TC): ...@@ -859,10 +837,10 @@ class test_SpooledTemporaryFile(TC):
if has_stat: if has_stat:
self.assertEqual(os.fstat(f.fileno()).st_size, 20) self.assertEqual(os.fstat(f.fileno()).st_size, 20)
test_classes.append(test_SpooledTemporaryFile)
if tempfile.NamedTemporaryFile is not tempfile.TemporaryFile:
class test_TemporaryFile(TC): class TestTemporaryFile(BaseTestCase):
"""Test TemporaryFile().""" """Test TemporaryFile()."""
def test_basic(self): def test_basic(self):
...@@ -909,10 +887,6 @@ class test_TemporaryFile(TC): ...@@ -909,10 +887,6 @@ class test_TemporaryFile(TC):
roundtrip("foo\r\n", "w+", newline="") roundtrip("foo\r\n", "w+", newline="")
if tempfile.NamedTemporaryFile is not tempfile.TemporaryFile:
test_classes.append(test_TemporaryFile)
# Helper for test_del_on_shutdown # Helper for test_del_on_shutdown
class NulledModules: class NulledModules:
def __init__(self, *modules): def __init__(self, *modules):
...@@ -929,7 +903,7 @@ class NulledModules: ...@@ -929,7 +903,7 @@ class NulledModules:
d.clear() d.clear()
d.update(c) d.update(c)
class test_TemporaryDirectory(TC): class TestTemporaryDirectory(BaseTestCase):
"""Test TemporaryDirectory().""" """Test TemporaryDirectory()."""
def do_create(self, dir=None, pre="", suf="", recurse=1): def do_create(self, dir=None, pre="", suf="", recurse=1):
...@@ -1071,10 +1045,8 @@ class test_TemporaryDirectory(TC): ...@@ -1071,10 +1045,8 @@ class test_TemporaryDirectory(TC):
self.assertFalse(os.path.exists(name)) self.assertFalse(os.path.exists(name))
test_classes.append(test_TemporaryDirectory)
def test_main(): def test_main():
support.run_unittest(*test_classes) support.run_unittest(__name__)
if __name__ == "__main__": if __name__ == "__main__":
test_main() test_main()
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