Thread: [Pydev-users] [pydev - Users] RE: How to use Run As > Python Unit Test
Brought to you by:
fabioz
From: SourceForge.net <no...@so...> - 2006-07-13 23:36:30
|
Read and respond to this message at: https://sourceforge.net/forum/message.php?msg_id=3821149 By: fabioz Well, it seems like a misconfiguration... If your pythonpath is not correctly configured it might not be able to run your unit-test (so, maybe your project source folder is not correctly configured?) Have you checked: http://fabioz.com/pydev/manual_101_root.html Cheers, Fabio ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge.net and visit: https://sourceforge.net/forum/unmonitor.php?forum_id=293649 |
From: SourceForge.net <no...@so...> - 2006-07-17 15:24:52
|
Read and respond to this message at: https://sourceforge.net/forum/message.php?msg_id=3824822 By: xsaero00 I have the pyhton path configured correctly. The source forlder in in the PyhtonPath. ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge.net and visit: https://sourceforge.net/forum/unmonitor.php?forum_id=293649 |
From: SourceForge.net <no...@so...> - 2006-07-17 17:11:38
|
Read and respond to this message at: https://sourceforge.net/forum/message.php?msg_id=3825054 By: drmaples can you post the code you are trying to run as "unit test". ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge.net and visit: https://sourceforge.net/forum/unmonitor.php?forum_id=293649 |
From: SourceForge.net <no...@so...> - 2006-07-17 19:01:06
|
Read and respond to this message at: https://sourceforge.net/forum/message.php?msg_id=3825327 By: xsaero00 Unit Test Code: import unittest from Packages.Utilities.validate import * class validateTest( unittest.TestCase ): """ Class to test validation functions """ def testIsLargeID(self): """ Test isLargeID function """ self.assert_( isLargeID( 1 ) ) self.assert_( isLargeID( '1' ) ) self.assert_( isLargeID( u'1' ) ) self.assert_( isLargeID( r'1' ) ) self.assert_( isLargeID( 0 ) ) self.assert_( isLargeID( '0' ) ) self.assert_( isLargeID( 00000000 ) ) self.assert_( isLargeID( '0000000' ) ) self.assert_( isLargeID( MAX_LARGE_ID ) ) self.assert_( isLargeID( MAX_SMALL_ID ) ) self.assert_( isLargeID( MIN_LARGE_ID ) ) self.assert_( not isLargeID( -1 ) ) self.assert_( not isLargeID( '-1' ) ) self.assert_( not isLargeID( u'-1' ) ) self.assert_( not isLargeID( None ) ) self.assert_( not isLargeID( '' ) ) self.assert_( not isLargeID( MAX_LARGE_ID + 1) ) self.assert_( not isLargeID( MIN_LARGE_ID - 1 ) ) self.assert_( not isLargeID( '0.0' ) ) self.assert_( not isLargeID( float( MAX_LARGE_ID ) ) ) def testIsSmallID(self): """ Test isSmallID function """ self.assert_( isSmallID( 1 ) ) self.assert_( isSmallID( '1' ) ) self.assert_( isSmallID( u'1' ) ) self.assert_( isSmallID( r'1' ) ) self.assert_( isSmallID( 0 ) ) self.assert_( isSmallID( '0' ) ) self.assert_( isSmallID( 00000000 ) ) self.assert_( isSmallID( '0000000' ) ) self.assert_( isSmallID( MAX_SMALL_ID ) ) self.assert_( isSmallID( MIN_SMALL_ID ) ) self.assert_( not isSmallID( -1 ) ) self.assert_( not isSmallID( '-1' ) ) self.assert_( not isSmallID( u'-1' ) ) self.assert_( not isSmallID( r'-1' ) ) self.assert_( not isSmallID( None ) ) self.assert_( not isSmallID( '' ) ) self.assert_( not isSmallID( ' ' ) ) self.assert_( not isSmallID( 'as' ) ) self.assert_( not isSmallID( '1a' ) ) self.assert_( not isSmallID( MAX_SMALL_ID + 1) ) self.assert_( not isSmallID( MIN_SMALL_ID - 1 ) ) self.assert_( not isSmallID( '0.0' ) ) self.assert_( not isSmallID( float( MAX_SMALL_ID ) ) ) def TestSuite(): return unittest.makeSuite(validateTest) if __name__ == '__main__': unittest.main() And here are the validation functions: def isLargeID( id ): """ Function to tell whether the id is a large id """ return isInteg( id ) and withinRange( id , MIN_LARGE_ID, MAX_LARGE_ID ) def isSmallID( id ): """ Function to tell whether the id is a small id """ return isInteg( id ) and withinRange( id , MIN_SMALL_ID, MAX_SMALL_ID ) def withinRange( value, min, max ): """ Function to check the range """ if isNumeric( value ) and isNumeric( min ) and isNumeric( max ): value = float( value ) min = float( min ) max = float( max ) return min <= max and value >= min and value <= max ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge.net and visit: https://sourceforge.net/forum/unmonitor.php?forum_id=293649 |
From: SourceForge.net <no...@so...> - 2006-07-17 23:26:33
|
Read and respond to this message at: https://sourceforge.net/forum/message.php?msg_id=3825886 By: fabioz Well, really strange, it should work... As it is difficult for me to reproduce it here, do you think you could try debugging the script yourself? It should be straightforward: Pydev has a script that is called for running the tests: org.python.pydev/pysrc/runfiles.py But now that I'm writing it, I just reminded that your problem might be the pydev version... earlier versions of pydev had a bug in that the unit-test would only run if you selected a folder (the problem was in that script), and not a .py file (this is already fixed, but as you didn't say your pydev version, this might be your problem). Cheers, Fabio ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge.net and visit: https://sourceforge.net/forum/unmonitor.php?forum_id=293649 |
From: SourceForge.net <no...@so...> - 2006-07-17 23:56:18
|
Read and respond to this message at: https://sourceforge.net/forum/message.php?msg_id=3825915 By: drmaples code seems ok, but try this: pydev 1.2.1 and below has a bug where some errors are silently ignored and 0 tests are reported as running. check that you do not have any syntax errors in the code that you are importing. the best thing to do is to change the code in runfiles.py to look like the code below. (this is fixed in the next ver of pydev) code located here: <ECLIPSE_INSTALL_DIR>/plugins/org.python.pydev.debug_1.2.1/pysrc/runfiles.py try: module = ImportModule(ModuleName(name, system_path)) tests = loader.loadTestsFromModule(module) alltests.append(tests) except Exception, msg: raise # <------ add me this #ok, unable to load the module (probably has not __init__.py in its folder structure) pass ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge.net and visit: https://sourceforge.net/forum/unmonitor.php?forum_id=293649 |
From: SourceForge.net <no...@so...> - 2006-07-21 23:06:32
|
Read and respond to this message at: https://sourceforge.net/forum/message.php?msg_id=3832965 By: xsaero00 Thanks. That helped. I had no idea that the sctipt that runs test first imports them as modules. In my Test folders I did not have __init__.py file because I had no reason for importing tests. I think somewhere in documentation it should mention that test folders have to be Python packages to be run as Unit Tests from context menu. ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge.net and visit: https://sourceforge.net/forum/unmonitor.php?forum_id=293649 |
From: SourceForge.net <no...@so...> - 2006-07-21 23:22:55
|
Read and respond to this message at: https://sourceforge.net/forum/message.php?msg_id=3832978 By: fabioz I think the test-runner could give a warning about it if it found no tests... what do you think? (if you agree, please open a feature request for it). Cheers, Fabio ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge.net and visit: https://sourceforge.net/forum/unmonitor.php?forum_id=293649 |