Skip to content

Commit f017a86

Browse files
committed
Merge pull request #698 from skrah/split_tests
Split tests
2 parents b2a388f + 40b3888 commit f017a86

38 files changed

Lines changed: 129 additions & 109 deletions

TESTING.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@ Running The Python Tests
22
========================
33

44
The Python tests are written using Python's built in unittest module,
5-
and can either be run by executing the scripts or with nose. To run
6-
a test script directly, simply execute the test .py file:
5+
and can either be run by executing the scripts or with nose. The two
6+
modules dynd.nd and dynd.ndt have separate tests. To run a test script
7+
directly, simply execute the test .py file.
78

8-
D:\Develop\dynd-python>python dynd\tests\test_dtype.py
9-
...........
10-
----------------------------------------------------------------------
11-
Ran 11 tests in 0.003s
9+
Examples:
1210

13-
OK
11+
D:\Develop\dynd-python>python dynd\ndt\test\test_type_basics.py
12+
D:\Develop\dynd-python>python dynd\nd\test\test_array_basics.py
1413

15-
To execute the full test suite, run the following (not from the root project
16-
directory):
14+
To execute the full test suite for both modules, run the following
15+
(not from the root project directory):
1716

1817
D:\Develop>python -c "import dynd; dynd.test()"
1918
Running unit tests for the DyND Python bindings

dynd/__init__.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ def test(verbosity=1, xunitfile=None, exit=False):
104104
"""
105105
import os, sys, subprocess
106106
import numpy
107-
from .tests import get_tst_module
107+
from .ndt.test import get_tst_module as ndt_test
108+
from .nd.test import get_tst_module as nd_test
108109
import unittest
109110

110111
print('Running unit tests for the DyND Python bindings')
@@ -120,9 +121,13 @@ def test(verbosity=1, xunitfile=None, exit=False):
120121
if xunitfile is None:
121122
# Run all the tests
122123
all_suites = []
123-
for fn in os.listdir(os.path.join(os.path.dirname(__file__), 'tests')):
124+
for fn in os.listdir(os.path.join(os.path.dirname(__file__), 'ndt/test')):
124125
if fn.startswith('test_') and fn.endswith('.py'):
125-
tst = get_tst_module(fn[:-3])
126+
tst = ndt_test(fn[:-3])
127+
all_suites.append(unittest.defaultTestLoader.loadTestsFromModule(tst))
128+
for fn in os.listdir(os.path.join(os.path.dirname(__file__), 'nd/test')):
129+
if fn.startswith('test_') and fn.endswith('.py'):
130+
tst = nd_test(fn[:-3])
126131
all_suites.append(unittest.defaultTestLoader.loadTestsFromModule(tst))
127132
runner = unittest.TextTestRunner(stream=sys.stdout, verbosity=verbosity)
128133
result = runner.run(unittest.TestSuite(all_suites))
@@ -140,8 +145,8 @@ def test(verbosity=1, xunitfile=None, exit=False):
140145
# Add all 'tests' subdirectories to the options
141146
rootdir = os.path.dirname(__file__)
142147
for root, dirs, files in os.walk(rootdir):
143-
if 'tests' in dirs:
144-
testsdir = os.path.join(root, 'tests')
148+
if 'test' in dirs:
149+
testsdir = os.path.join(root, 'test')
145150
argv.append(testsdir)
146151
print('Test dir: %s' % testsdir[len(rootdir)+1:])
147152
# Ask nose to do its thing
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,4 +376,4 @@ def f(x, y):
376376
pass
377377

378378
if __name__ == '__main__':
379-
unittest.main()
379+
unittest.main(verbosity=2)
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import unittest
2-
from dynd import nd, ndt
2+
from dynd import nd
33
import sys
44

55
@unittest.skip('Test disabled since translate_exception is not being applied properly')
@@ -40,3 +40,6 @@ def test_arithmetic_exceptions(self):
4040
# but should not fail silently.
4141
self.assertRaises(ValueError, a.__pow__, a, a)
4242
self.assertRaises(RuntimeError, a.__rpow__, b)
43+
44+
if __name__ == '__main__':
45+
unittest.main(verbosity=2)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@ def test_struct_or_tuple(self):
4646
""")
4747
a = nd.array(data, type=tp)
4848
self.assertEqual(nd.as_py(a), data)
49+
50+
if __name__ == '__main__':
51+
unittest.main(verbosity=2)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ def test_array_complex(self):
4848
self.assertEqual(complex(a), 1.125e-20+3j)
4949

5050
if __name__ == '__main__':
51-
unittest.main()
51+
unittest.main(verbosity=2)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,4 +720,4 @@ def test_scalar_option(self):
720720
# (u'\uc548\ub155', u'\uc548\ub155')])
721721

722722
if __name__ == '__main__':
723-
unittest.main()
723+
unittest.main(verbosity=2)
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import sys
22
import unittest
3-
from datetime import date
43
from dynd import nd, ndt
54
import numpy as np
65

@@ -241,4 +240,4 @@ def test_string_assign_to_slice(self):
241240

242241

243242
if __name__ == '__main__':
244-
unittest.main()
243+
unittest.main(verbosity=2)

0 commit comments

Comments
 (0)