
import os
from tempfile import mkdtemp
from shutil import rmtree

from nipy.testing import *
from sneeze import find_pkg, run_nose

import_strings = ["from nipype.interfaces.afni import To3d",
                  "from nipype.interfaces import afni",
                  "import nipype.interfaces.afni"]

def test_from_namespace():
    dname = mkdtemp()
    fname = os.path.join(dname, 'test_afni.py')
    fp = open(fname, 'w')
    fp.write('from nipype.interfaces.afni import To3d')
    fp.close()
    cover_pkg, module = find_pkg(fname)
    cmd = run_nose(cover_pkg, fname, dry_run=True)
    cmdlst = cmd.split()
    cmd = ' '.join(cmdlst[:4]) # strip off temporary directory path
    #print cmd
    assert_equal(cmd, 'nosetests -sv --with-coverage --cover-package=nipype.interfaces.afni')
    if os.path.exists(dname):
        rmtree(dname)

@@ -184,16 +184,29 @@
 ort To3d
+, ThreeDRefit
 %22,%0A     
@@ -309,34 +309,89 @@
 fni%22
-%5D%0A%0Adef test_from_namespace
+,%0A                  %22from nipype.interfaces import afni as af%22%5D%0A%0Adef test_imports
 ():%0A
@@ -460,16 +460,52 @@
 ni.py')%0A
+    for impt in import_strings:%0A    
     fp =
@@ -526,16 +526,20 @@
 w')%0A    
+ 
+   
 fp.write
@@ -543,51 +543,18 @@
 ite(
-'from nipype.interfaces.afni import To3d')%0A
+impt)%0A    
     
@@ -564,16 +564,20 @@
 close()%0A
+    
     cove
@@ -608,24 +608,28 @@
 (fname)%0A    
+   
+ 
 cmd = run_no
@@ -663,16 +663,20 @@
 n=True)%0A
+    
     cmdl
@@ -692,24 +692,28 @@
 split()%0A    
+  
+  
 cmd = ' '.jo
@@ -772,22 +772,17 @@
     
-#print cmd%0A   
+    yield
  ass
@@ -794,13 +794,24 @@
 qual
-(
+, 
 cmd,
+ %5C%0A       
  'no
@@ -877,17 +877,16 @@
 es.afni'
-)
 %0A    if 

Add more tests for sneeze.