-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring for changed module level name.
- Loading branch information
1 parent
41fa873
commit 77745ab
Showing
12 changed files
with
205 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
124 changes: 62 additions & 62 deletions
124
test/shared/corso/test_data.py → test/shared/tools/test_data.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,63 @@ | ||
import unittest, doctest | ||
|
||
from org.apache.commons.lang3.time import DateUtils | ||
from java.util import Date | ||
|
||
from shared.corso.data import * | ||
|
||
|
||
doctest.run_docstring_examples(datasetToListDict,globals()) | ||
doctest.run_docstring_examples(datasetToDictList,globals()) | ||
doctest.run_docstring_examples(gatherKeys,globals()) | ||
doctest.run_docstring_examples(listDictToDataset,globals()) | ||
|
||
|
||
class RecordSetTestCase(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.columnNames = 'c1 c2 c3'.split() | ||
self.numColumns = len(self.columnNames) | ||
self.numRows = 4 | ||
self.RecordSet = genRecordSet(self.columnNames) | ||
|
||
def tearDown(self): | ||
pass | ||
|
||
# Test different inputs | ||
def test_readListOfLists(self): | ||
# generate source data | ||
listOfLists= [list(range(i,i+self.numColumns)) | ||
for i in range(1,self.numRows*self.numColumns,self.numColumns)] | ||
|
||
# generate test data | ||
listOfRecordSets = [self.RecordSet(row) for row in listOfLists] | ||
|
||
# check dimensions | ||
self.assertTrue(all(len(listOfRecordSets[i].keys()) for i in range(self.numColumns))) | ||
self.assertEqual(len(listOfRecordSets), self.numRows) | ||
|
||
# verify data imported correctly | ||
for lotRow,lorsRow in zip(listOfLists, listOfRecordSets): | ||
self.assertEqual(lotRow,list(lorsRow)) | ||
|
||
# Test different inputs | ||
def test_readListOfTuples(self): | ||
# generate source data | ||
listOfTuples = [tuple(range(i,i+self.numColumns)) | ||
for i in range(1,self.numRows*self.numColumns,self.numColumns)] | ||
|
||
# generate test data | ||
listOfRecordSets = [self.RecordSet(row) for row in listOfTuples] | ||
|
||
# check dimensions | ||
self.assertTrue(all(len(listOfRecordSets[i].keys()) for i in range(self.numColumns))) | ||
self.assertEqual(len(listOfRecordSets), self.numRows) | ||
|
||
# verify data imported correctly | ||
for lotRow,lorsRow in zip(listOfTuples, listOfRecordSets): | ||
self.assertEqual(lotRow,tuple(lorsRow)) | ||
|
||
|
||
suite = unittest.TestLoader().loadTestsFromTestCase(RecordSetTestCase) | ||
|
||
import unittest, doctest | ||
|
||
from org.apache.commons.lang3.time import DateUtils | ||
from java.util import Date | ||
|
||
from shared.tools.data import * | ||
|
||
|
||
doctest.run_docstring_examples(datasetToListDict,globals()) | ||
doctest.run_docstring_examples(datasetToDictList,globals()) | ||
doctest.run_docstring_examples(gatherKeys,globals()) | ||
doctest.run_docstring_examples(listDictToDataset,globals()) | ||
|
||
|
||
class RecordSetTestCase(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.columnNames = 'c1 c2 c3'.split() | ||
self.numColumns = len(self.columnNames) | ||
self.numRows = 4 | ||
self.RecordSet = genRecordSet(self.columnNames) | ||
|
||
def tearDown(self): | ||
pass | ||
|
||
# Test different inputs | ||
def test_readListOfLists(self): | ||
# generate source data | ||
listOfLists= [list(range(i,i+self.numColumns)) | ||
for i in range(1,self.numRows*self.numColumns,self.numColumns)] | ||
|
||
# generate test data | ||
listOfRecordSets = [self.RecordSet(row) for row in listOfLists] | ||
|
||
# check dimensions | ||
self.assertTrue(all(len(listOfRecordSets[i].keys()) for i in range(self.numColumns))) | ||
self.assertEqual(len(listOfRecordSets), self.numRows) | ||
|
||
# verify data imported correctly | ||
for lotRow,lorsRow in zip(listOfLists, listOfRecordSets): | ||
self.assertEqual(lotRow,list(lorsRow)) | ||
|
||
# Test different inputs | ||
def test_readListOfTuples(self): | ||
# generate source data | ||
listOfTuples = [tuple(range(i,i+self.numColumns)) | ||
for i in range(1,self.numRows*self.numColumns,self.numColumns)] | ||
|
||
# generate test data | ||
listOfRecordSets = [self.RecordSet(row) for row in listOfTuples] | ||
|
||
# check dimensions | ||
self.assertTrue(all(len(listOfRecordSets[i].keys()) for i in range(self.numColumns))) | ||
self.assertEqual(len(listOfRecordSets), self.numRows) | ||
|
||
# verify data imported correctly | ||
for lotRow,lorsRow in zip(listOfTuples, listOfRecordSets): | ||
self.assertEqual(lotRow,tuple(lorsRow)) | ||
|
||
|
||
suite = unittest.TestLoader().loadTestsFromTestCase(RecordSetTestCase) | ||
|
||
unittest.TextTestRunner(verbosity=2).run(suite) |
12 changes: 6 additions & 6 deletions
12
test/shared/corso/test_logging.py → test/shared/tools/test_logging.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import unittest, doctest | ||
|
||
from shared.corso.logging import BaseLogger | ||
|
||
doctest.run_docstring_examples(BaseLogger()._generateMessage,globals()) | ||
doctest.run_docstring_examples(BaseLogger()._formatString, globals(), optionflags=doctest.ELLIPSIS) | ||
import unittest, doctest | ||
|
||
from shared.tools.logging import BaseLogger | ||
|
||
doctest.run_docstring_examples(BaseLogger()._generateMessage,globals()) | ||
doctest.run_docstring_examples(BaseLogger()._formatString, globals(), optionflags=doctest.ELLIPSIS) | ||
doctest.run_docstring_examples(BaseLogger()._bracketString, globals()) |
126 changes: 63 additions & 63 deletions
126
test/shared/corso/test_meta.py → test/shared/tools/test_meta.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,64 @@ | ||
import unittest, doctest | ||
|
||
from shared.corso.meta import sentinel, getFunctionCallSigs | ||
|
||
doctest.run_docstring_examples(sentinel,globals()) | ||
doctest.run_docstring_examples(getFunctionCallSigs,globals()) | ||
|
||
|
||
from shared.corso.meta import currentStackDepth, getObjectByName, getObjectName | ||
|
||
|
||
class ObjectSearchTestCase(unittest.TestCase): | ||
|
||
def test_stackSearch(self): | ||
# Generate a stack search | ||
def foo(): | ||
x = 33 | ||
def bar(): | ||
y = 2 | ||
def baz(): | ||
z = 3 | ||
x = 725 | ||
|
||
currentDepth = currentStackDepth() | ||
|
||
# Start in this stack frame, go into the past | ||
self.assertEqual(725, getObjectByName('x')) | ||
# Start at the deepest past, and go towards the current stack frame | ||
self.assertEqual(33, getObjectByName('x', startRecent=False)) | ||
# Start at the deepest past and go deeper (before foo was defined!) | ||
self.assertEqual(None, getObjectByName('x', currentDepth)) | ||
# start at the deepest past and come towards the current stack frame | ||
self.assertEqual(33, getObjectByName('x', currentDepth, startRecent=False)) | ||
|
||
self.assertEqual('foo', getObjectName(foo)) | ||
baz() | ||
bar() | ||
foo() | ||
|
||
def test_PythonFunctionSigs(self): | ||
# Generate a few different functions to verify signatures. | ||
def fun1(): | ||
pass | ||
def fun2(x,y,z=5): | ||
pass | ||
self.assertEqual('()', getFunctionCallSigs(fun1)) | ||
self.assertEqual('(x, y, z=5)', getFunctionCallSigs(fun2)) | ||
|
||
def test_JavaFunctionSigs(self): | ||
from java.util import Random | ||
|
||
# Check the no args case | ||
self.assertEqual('()', getFunctionCallSigs(Random().nextBoolean)) | ||
# Check the single call method case | ||
self.assertEqual('(<long>)', getFunctionCallSigs(Random().setSeed)) | ||
# Check the many ways to call case | ||
self.assertEqual('() -OR- (<long>) -OR- (<int>, <int>) -OR- (<long>, <int>, <int>)', getFunctionCallSigs(Random().ints)) | ||
# Try a different join method | ||
self.assertEqual('()|(<long>)|(<int>, <int>)|(<long>, <int>, <int>)', getFunctionCallSigs(Random().ints, joinClause='|')) | ||
|
||
|
||
suite = unittest.TestLoader().loadTestsFromTestCase(ObjectSearchTestCase) | ||
unittest.TextTestRunner(verbosity=2).run(suite) | ||
import unittest, doctest | ||
|
||
from shared.tools.meta import sentinel, getFunctionCallSigs | ||
|
||
doctest.run_docstring_examples(sentinel,globals()) | ||
doctest.run_docstring_examples(getFunctionCallSigs,globals()) | ||
|
||
|
||
from shared.tools.meta import currentStackDepth, getObjectByName, getObjectName | ||
|
||
|
||
class ObjectSearchTestCase(unittest.TestCase): | ||
|
||
def test_stackSearch(self): | ||
# Generate a stack search | ||
def foo(): | ||
x = 33 | ||
def bar(): | ||
y = 2 | ||
def baz(): | ||
z = 3 | ||
x = 725 | ||
|
||
currentDepth = currentStackDepth() | ||
|
||
# Start in this stack frame, go into the past | ||
self.assertEqual(725, getObjectByName('x')) | ||
# Start at the deepest past, and go towards the current stack frame | ||
self.assertEqual(33, getObjectByName('x', startRecent=False)) | ||
# Start at the deepest past and go deeper (before foo was defined!) | ||
self.assertEqual(None, getObjectByName('x', currentDepth)) | ||
# start at the deepest past and come towards the current stack frame | ||
self.assertEqual(33, getObjectByName('x', currentDepth, startRecent=False)) | ||
|
||
self.assertEqual('foo', getObjectName(foo)) | ||
baz() | ||
bar() | ||
foo() | ||
|
||
def test_PythonFunctionSigs(self): | ||
# Generate a few different functions to verify signatures. | ||
def fun1(): | ||
pass | ||
def fun2(x,y,z=5): | ||
pass | ||
self.assertEqual('()', getFunctionCallSigs(fun1)) | ||
self.assertEqual('(x, y, z=5)', getFunctionCallSigs(fun2)) | ||
|
||
def test_JavaFunctionSigs(self): | ||
from java.util import Random | ||
|
||
# Check the no args case | ||
self.assertEqual('()', getFunctionCallSigs(Random().nextBoolean)) | ||
# Check the single call method case | ||
self.assertEqual('(<long>)', getFunctionCallSigs(Random().setSeed)) | ||
# Check the many ways to call case | ||
self.assertEqual('() -OR- (<long>) -OR- (<int>, <int>) -OR- (<long>, <int>, <int>)', getFunctionCallSigs(Random().ints)) | ||
# Try a different join method | ||
self.assertEqual('()|(<long>)|(<int>, <int>)|(<long>, <int>, <int>)', getFunctionCallSigs(Random().ints, joinClause='|')) | ||
|
||
|
||
suite = unittest.TestLoader().loadTestsFromTestCase(ObjectSearchTestCase) | ||
unittest.TextTestRunner(verbosity=2).run(suite) | ||
|
12 changes: 6 additions & 6 deletions
12
test/shared/corso/test_thread.py → test/shared/tools/test_thread.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import unittest, doctest | ||
|
||
|
||
from shared.coros.thread import async | ||
|
||
|
||
import unittest, doctest | ||
|
||
|
||
from shared.coros.thread import async | ||
|
||
|
||
doctest.run_docstring_examples(async, globals(), optionflags=doctest.ELLIPSIS) |
Oops, something went wrong.