mirror of
https://github.com/wassname/simpeg.git
synced 2026-06-27 21:08:35 +08:00
Merge pull request #229 from simpeg/test/examples
add test to ensure examples are up to date
This commit is contained in:
@@ -1,8 +1,28 @@
|
||||
import unittest
|
||||
import sys
|
||||
import os
|
||||
from SimPEG import Examples
|
||||
import numpy as np
|
||||
|
||||
class compareInitFiles(unittest.TestCase):
|
||||
def test_compareInitFiles(self):
|
||||
print 'Checking that __init__.py up-to-date in SimPEG/Examples'
|
||||
fName = os.path.abspath(__file__)
|
||||
ExamplesDir = os.path.sep.join(fName.split(os.path.sep)[:-3] + ['SimPEG', 'Examples'])
|
||||
|
||||
files = os.listdir(ExamplesDir)
|
||||
|
||||
pyfiles = []
|
||||
[pyfiles.append(py.rstrip('.py')) for py in files if py.endswith('.py') and py != '__init__.py']
|
||||
|
||||
setdiff = set(pyfiles) - set(Examples.__examples__)
|
||||
|
||||
print ' Any missing files? ', setdiff
|
||||
|
||||
didpass = (setdiff == set())
|
||||
|
||||
self.assertTrue(didpass, "Examples not up to date, run 'python __init__.py' from SimPEG/Examples to update")
|
||||
|
||||
def get(test):
|
||||
def test_func(self):
|
||||
print '\nTesting %s.run(plotIt=False)\n'%test
|
||||
@@ -10,11 +30,11 @@ def get(test):
|
||||
self.assertTrue(True)
|
||||
return test_func
|
||||
attrs = dict()
|
||||
|
||||
for test in Examples.__examples__:
|
||||
attrs['test_'+test] = get(test)
|
||||
|
||||
TestExamples = type('TestExamples', (unittest.TestCase,), attrs)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user