Commit 04055dee by rfkelly0

improve ThreadingTestCases.test_FSTestCases_in_separate_dirs.

It's now called "test_cases_in_separate_dirs" and uses tests defined on
self.__class__ rather than the base FSTestCase suite.
parent 87674ab0
...@@ -17,6 +17,7 @@ import unittest ...@@ -17,6 +17,7 @@ import unittest
import os, os.path import os, os.path
import pickle import pickle
import random import random
import copy
import time import time
try: try:
...@@ -470,7 +471,6 @@ class FSTestCases: ...@@ -470,7 +471,6 @@ class FSTestCases:
r = random.Random(0) r = random.Random(0)
for i in xrange(num_chunks): for i in xrange(num_chunks):
yield "".join(chr(r.randint(0,255)) for j in xrange(chunk_size)) yield "".join(chr(r.randint(0,255)) for j in xrange(chunk_size))
for i in xrange(5):
f = self.fs.open("bigfile","wb") f = self.fs.open("bigfile","wb")
try: try:
for chunk in chunk_stream(): for chunk in chunk_stream():
...@@ -572,15 +572,15 @@ class ThreadingTestCases: ...@@ -572,15 +572,15 @@ class ThreadingTestCases:
# that's ok, some implementations don't support concurrent writes # that's ok, some implementations don't support concurrent writes
pass pass
def test_FSTestCases_in_separate_dirs(self): def test_cases_in_separate_dirs(self):
class RunFSTestCases(unittest.TestCase,FSTestCases): class TestCases_in_subdir(self.__class__):
"""Run all FSTestCases against a subdir of self.fs""" """Run all testcases against a subdir of self.fs"""
def __init__(this,subdir): def __init__(this,subdir):
this.subdir = subdir this.subdir = subdir
for meth in dir(this): for meth in dir(this):
if not meth.startswith("test_"): if not meth.startswith("test_"):
continue continue
if meth == "test_pickling": if meth in ("test_pickling","test_cases_in_separate_dirs"):
continue continue
if self.fs.exists(subdir): if self.fs.exists(subdir):
self.fs.removedir(subdir,force=True) self.fs.removedir(subdir,force=True)
...@@ -594,11 +594,11 @@ class ThreadingTestCases: ...@@ -594,11 +594,11 @@ class ThreadingTestCases:
def check(this,p): def check(this,p):
return self.check(pathjoin(this.subdir,relpath(p))) return self.check(pathjoin(this.subdir,relpath(p)))
def thread1(): def thread1():
RunFSTestCases("thread1") TestCases_in_subdir("thread1")
def thread2(): def thread2():
RunFSTestCases("thread2") TestCases_in_subdir("thread2")
def thread3(): def thread3():
RunFSTestCases("thread3") TestCases_in_subdir("thread3")
self._runThreads(thread1,thread2,thread3) self._runThreads(thread1,thread2,thread3)
def test_makedir_winner(self): def test_makedir_winner(self):
......
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