[openstack-dev] Does python2.6 not support 'with assertRaises()'?

Paul Michali pcm at cisco.com
Fri Feb 8 18:25:02 UTC 2013


Did some googling and it looks like 2.6 doesn't support assertRaises as a context manager.


PCM (Paul Michali)

On Feb 8, 2013, at 1:17 PM, Paul Michali wrote:

> I'm working on a bug and I had this code, which passes UT on my system running python2.7, but fails Jenkin's python2.6 run:
> 
>      def test_missing_required_config(self):
>          args = ['--config-file',
>                  os.path.join(TEST_ETC_AREA, 'bad-quantum.conf.test')]
>          with self.assertRaises(cfg.RequiredOptError):
>              config.parse(args=args)
> 
> First Jenkins failure (looks like python2.6) says:
> 
> ft116.1: quantum.tests.unit.test_config.RequiredConfigTest.test_missing_required_configTraceback (most recent call last):
>   File "/usr/lib/python2.6/unittest.py", line 279, in run
>     testMethod()
>   File "/home/jenkins/workspace/gate-quantum-python26/quantum/tests/unit/test_config.py", line 59, in test_missing_required_config
>     with self.assertRaises(cfg.RequiredOptError):
> TypeError: failUnlessRaises() takes at least 3 arguments (2 given)
> Is there an issue with 2.6 supporting with clause and assertRaises, or is there a backward compatibility issue? I'm trying changing it to this...
> 
>     def test_missing_required_config(self):
>         args = ['--config-file',
>                 os.path.join(TEST_ETC_AREA, 'bad-quantum.conf.test')]
>         self.assertRaises(cfg.RequiredOptError, config.parse, args=args)
> 
> 
> PCM (Paul Michali)
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20130208/d053a3ea/attachment.html>


More information about the OpenStack-dev mailing list