pydoc errors
python version is 2.6.2 does any one else have this issue? Seen a few closed tickets for various Linux Distros but it is obvoiusly still my problem. help> modules Please wait a moment while I gather a list of all available modules... dm.c: 1640: not running as root returning empty list ** (.:8391): WARNING **: Trying to register gtype 'WnckWindowState' as flags when in fact it is of type 'GEnum' ** (.:8391): WARNING **: Trying to register gtype 'WnckWindowActions' as flags when in fact it is of type 'GEnum' ** (.:8391): WARNING **: Trying to register gtype 'WnckWindowMoveResizeMask' as flags when in fact it is of type 'GEnum' /usr/lib/python2.6/site-packages/httplib2/__init__.py:29: DeprecationWarning: the md5 module is deprecated; use hashlib instead import md5 /usr/lib/python2.6/site-packages/httplib2/__init__.py:44: DeprecationWarning: the sha module is deprecated; use the hashlib module instead import sha 2010-02-25 01:20:10.483800: ERROR: Could not load the stocks from /home/jmaclean/.gnome2/invest-applet/stocks.pickle: [Errno 2] No such file or directory: '/home/jmaclean/.gnome2/invest-applet/stocks.pickle' You must run this application as root -- John Maclean 07739 171 531 MSc (DIC) Enterprise Linux Systems Engineer -- http://mail.python.org/mailman/listinfo/python-list
Code dojo on Thursday?
Is there a code Dojo in London on Thurs? I've requested two places but have not heard a reply yet. -- John Maclean MSc. (DIC) Bsc. (Hons),Core Linux Systems Engineering,07739 171 531 -- http://mail.python.org/mailman/listinfo/python-list
Unit testing errors (testing the platform module)
I normally use languages unit testing framework to get a better understanding of how a language works. Right now I want to grok the platform module; 1 #!/usr/bin/env python 2 '''a pythonic factor''' 3 import unittest 4 import platform 5 6 class TestPyfactorTestCase(unittest.TestCase): 7 def setUp(self): 8 '''setting up stuff''' 13 14 def testplatformbuiltins(self): 15 '''platform.__builtins__.blah ''' 16 self.assertEquals(platform.__builtins__.__class__, "") 17 18 19 def tearDown(self): 20 print 'cleaning stuff up' 21 22 if __name__ == "__main__": 23 unittest.main() Is there an error in my syntax? Why is my test failing? Line 16. python stfu/testing/test_pyfactor.py Fcleaning stuff up == FAIL: platform.__builtins__.blah -- Traceback (most recent call last): File "stfu/testing/test_pyfactor.py", line 16, in testplatformbuiltins self.assertEquals(platform.__builtins__.__class__, "") AssertionError: != "" -- Ran 1 test in 0.000s FAILED (failures=1) -- John Maclean MSc. (DIC) Bsc. (Hons),Core Linux Systems Engineering,07739 171 531 -- http://mail.python.org/mailman/listinfo/python-list
unit testing, setUp and scoping
Can one use the setUp block to store variables so that they can be used elsewhere in unit tests? I'm thinking that it's better to have variables created in another script and have it imported from within the unit test #!/usr/bin/env python '''create knowledge base of strings by unit testing''' import unittest class TestPythonStringsTestCase(unittest.TestCase): def setUp(self): print '''setting up stuff for ''', __name__ s1 = 'single string' print dir(str) def testclass(self): '''test strings are of class str''' self.assertEqual(s1.__class__, str) if __name__ == "__main__": unittest.main() -- John Maclean 07739 171 531 MSc (DIC) Enterprise Linux Systems Engineer -- http://mail.python.org/mailman/listinfo/python-list
Re: Unit testing errors (testing the platform module)
On 14 April 2010 09:09, Gabriel Genellina wrote: > En Tue, 13 Apr 2010 11:01:19 -0300, John Maclean > escribió: > >> Is there an error in my syntax? Why is my test failing? Line 16. >> >> == >> FAIL: platform.__builtins__.blah >> -- >> Traceback (most recent call last): >> File "stfu/testing/test_pyfactor.py", line 16, in testplatformbuiltins >> self.assertEquals(platform.__builtins__.__class__, "") >> AssertionError: != "" >> >> -- > > To express the condition "SOMEOBJECT must be a dictionary", use: > > isinstance(SOMEOBJECT, dict) > > SOMEOBJECT might actually be an instance of any derived class and still pass > the test; that's usually the desired behavior. > > In the rare cases where only a very specific type is allowed, use this form > instead: > > type(SOMEOBJECT) is dict > > > The test case above should read then: > > self.assert_(isinstance(platform.__builtins__, dict), > type(platform.__builtins__)) > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > This is cool. Thanks for your replies. self.assertEqual(platform.__builtins__.__class__, dict, "platform.__class__ supposed to be dict") self.assertEqual(platform.__name__, 'platform' ) -- John Maclean 07739 171 531 MSc (DIC) Enterprise Linux Systems Engineer -- http://mail.python.org/mailman/listinfo/python-list
Re: unit testing, setUp and scoping
On 14 April 2010 16:22, Francisco Souza wrote: >> On Wed, Apr 14, 2010 at 11:47 AM, john maclean wrote: >> Can one use the setUp block to store variables so that they can be >> used elsewhere in unit tests? I'm thinking that it's better to have >> variables created in another script and have it imported from within >> the unit test > > Hi John, > each TestCase is a object, and you can "store" attributes in this objects > normally, using self :) > > class TestPythonStringsTestCase( >> >> unittest.TestCase): >> def setUp(self): >> print '''setting up stuff for ''', __name__ >> self.s1 = 'single string' >> print dir(str) >> >> def testclass(self): >> '''test strings are of class str''' >> self.assertEqual(self.s1.__class__, str) >> >> if __name__ == "__main__": >> unittest.main() > > This works fine and s1 is an internal attribute of your TesteCase. > > Best regards, > Francisco Souza > Software developer at Giran and also full time > Open source evangelist at full time > > http://www.franciscosouza.net > Twitter: @franciscosouza > (27) 8128 0652 > > -- > http://mail.python.org/mailman/listinfo/python-list > > Thanks! that worked. -- John Maclean 07739 171 531 MSc (DIC) Enterprise Linux Systems Engineer -- http://mail.python.org/mailman/listinfo/python-list
unittest not being run
hi, can some one explain why the __first__ test is not being run? #!/usr/bin/env python import unittest # {{{ class T1TestCase(unittest.TestCase): def setUp(self): pass # can we use global variables here? def tearDown(self): pass # garbage collection def test_T1(self): '''this test aint loading''' self.assertEquals(1, 0) def test_T2(self): ## test method names begin 'test*' self.assertEquals((1 + 2), 3) self.assertEquals(0 + 1, 1) def test_T3(self): self.assertEquals((0 * 10), 0) self.assertEquals((5 * 8), 40) # the output is better. prints each test and ok or fail suite = unittest.TestLoader().loadTestsFromTestCase(T1TestCase) unittest.TextTestRunner(verbosity=2).run(suite) # }}} ''' halp! the first test ain't loading... python blaht.py test_T2 (__main__.T1TestCase) ... ok test_T3 (__main__.T1TestCase) ... ok -- Ran 2 tests in 0.000s OK ''' -- http://mail.python.org/mailman/listinfo/python-list
Re: unittest not being run
On 10/05/2010 14:38, J. Cliff Dyer wrote: My guess is you mixed tabs and spaces. One tab is always treated by the python interpreter as being equal to eight spaces, which is two indentation levels in your code. Though if it were exactly as you show it, you'd be getting a syntax error, because even there, it looks like the indentation of your `def test_T1(self):` line is off by one column, relative to pass, and by three columns relative to the other methods. Cheers, Cliff 'twas a spaces/indent issue. thanks! -- http://mail.python.org/mailman/listinfo/python-list
unittest basics
is there a way to test that a certian library or module is or can be loaded successfully? self.assert('import blah') -- John Maclean MSc. (DIC) BSc. (Hons) Linux Systems and Applications 07739 171 531 -- http://mail.python.org/mailman/listinfo/python-list
pythonic ssh
hi, pyssh, pexpect, paramiko or creating your your own sockets. what do you use to pythonically ssh to boxes? -- John Maclean MSc. (DIC) BSc. (Hons) Linux Systems and Applications 07739 171 531 -- http://mail.python.org/mailman/listinfo/python-list