> But why isn't your method equivalent to specifying the argument in the
> custom-run configuration? I thought that everything that I enter there
> is simply passed on to sys.argv of my Python program...


Hi,

Yes, it's the same... It's just that I usually find it more convenient
to edit it there.

Cheers,

Fabio


> Best,
>
> -Nikolaus
>
>
> Fabio Zadrozny <fabi...@gmail.com> writes:
>> Usually, what I do to run only one test is setting the main part to:
>>
>> if __name__ == '__main__':
>>     import sys;sys.argv=['', 'Test.test_one']
>>     unittest.main()
>>
>> You could also do a suite and call that suite, but I find that way
>> easier (and yes, pydev should have a better support to run only one
>> method from a test case... can you create a feature request for that?)
>>
>> Cheers,
>>
>> Fabio
>>
>> On Tue, Jun 9, 2009 at 8:20 PM, Nikolaus Rath<nikol...@rath.org> wrote:
>>> Hello,
>>>
>>> Is it possible to run only a specific test function from a testcase?
>>>
>>> I tried to run the following file
>>>
>>> ,----
>>> | import unittest
>>> |
>>> | class Test(unittest.TestCase):
>>> |
>>> |     def test_one(self):
>>> |         self.assertTrue(1+1 == 2)
>>> |
>>> |     def test_two(self):
>>> |         self.assertTrue(1+1 == 3)
>>> |
>>> | if __name__ == "__main__":
>>> |     unittest.main()
>>> `----
>>>
>>> with a custom-run configuration derived from "Python unit-test" where I
>>> set the arguments to "Test.test_one" (or just "test_one"). But instead
>>> of running only the first test, this produces the following error in the
>>> console:
>>>
>>> ,----
>>> | Traceback (most recent call last):
>>> |   File 
>>> "/home/nikratio/lib/eclipse/plugins/org.python.pydev.debug_1.4.6.2788/pysrc/runfiles.py",
>>>  line 257, in <module>
>>> |     PydevTestRunner(dirs, test_filter, verbosity).run_tests()
>>> |   File 
>>> "/home/nikratio/lib/eclipse/plugins/org.python.pydev.debug_1.4.6.2788/pysrc/runfiles.py",
>>>  line 69, in __init__
>>> |     self.__adjust_path()
>>> |   File 
>>> "/home/nikratio/lib/eclipse/plugins/org.python.pydev.debug_1.4.6.2788/pysrc/runfiles.py",
>>>  line 86, in __adjust_path
>>> |     raise RuntimeError(msg)
>>> | RuntimeError: unknown type.
>>> | Test.test_one
>>> | should be file or a directory.
>>> `----
>>>
>>>
>>>
>>> Best,
>>>
>>>
>>>
>>>   -Nikolaus
>>>
>>> --
>>>  »Time flies like an arrow, fruit flies like a Banana.«
>>>
>>>  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Crystal Reports - New Free Runtime and 30 Day Trial
>>> Check out the new simplified licensing option that enables unlimited
>>> royalty-free distribution of the report engine for externally facing
>>> server and web deployment.
>>> http://p.sf.net/sfu/businessobjects
>>> _______________________________________________
>>> Pydev-users mailing list
>>> Pydev-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/pydev-users
>>>
>>
>> ------------------------------------------------------------------------------
>> Crystal Reports - New Free Runtime and 30 Day Trial
>> Check out the new simplified licensing option that enables unlimited
>> royalty-free distribution of the report engine for externally facing
>> server and web deployment.
>> http://p.sf.net/sfu/businessobjects
>
>
>   -Nikolaus
>
> --
>  »Time flies like an arrow, fruit flies like a Banana.«
>
>  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C
>
>
> ------------------------------------------------------------------------------
> Crystal Reports - New Free Runtime and 30 Day Trial
> Check out the new simplified licensing option that enables unlimited
> royalty-free distribution of the report engine for externally facing
> server and web deployment.
> http://p.sf.net/sfu/businessobjects
> _______________________________________________
> Pydev-users mailing list
> Pydev-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pydev-users
>

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Pydev-users mailing list
Pydev-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pydev-users

Reply via email to