| 
					
				 | 
			
			
				@@ -1,4 +1,8 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// Qt includes 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+#include <QTemporaryFile> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+#include <QTextStream> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // CTK includes 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #include "ctkAbstractPythonManager.h" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #include "ctkTest.h" 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -43,7 +47,8 @@ private Q_SLOTS: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   void testExecuteString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   void testExecuteString_data(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  //void testExecuteFile(); // TODO 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  void testExecuteFile(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  void testExecuteFile_data(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   //void testPythonAttributes(); // TODO 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -165,5 +170,41 @@ void ctkAbstractPythonManagerTester::testExecuteString_data() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // ---------------------------------------------------------------------------- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+void ctkAbstractPythonManagerTester::testExecuteFile() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  QFETCH(QString, stringToExecute); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  QFETCH(bool, pythonErrorExpected); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  QTemporaryFile pythonFile("testExecuteFile-XXXXXX.py"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  QVERIFY(pythonFile.open()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  QTextStream out(&pythonFile); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  out << stringToExecute; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  pythonFile.close(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  this->PythonManager.executeFile(pythonFile.fileName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  QCOMPARE(this->PythonManager.pythonErrorOccured(), pythonErrorExpected); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// ---------------------------------------------------------------------------- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+void ctkAbstractPythonManagerTester::testExecuteFile_data() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  QTest::addColumn<QString>("stringToExecute"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  QTest::addColumn<bool>("pythonErrorExpected"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  QTest::newRow("0-emptyfile") << QString("") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                     << false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  QTest::newRow("1-helloworld") << QString("print 'Hello world'") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                     << false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  QTest::newRow("2-syntaxerror") << QString("print '") // SyntaxError 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                     << true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  QTest::newRow("3-check __file__ attribute") << QString("print 'This file is: %s' % __file__") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                     << false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// ---------------------------------------------------------------------------- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 CTK_TEST_MAIN(ctkAbstractPythonManagerTest) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #include "moc_ctkAbstractPythonManagerTest.cpp" 
			 |