pyrollbar icon indicating copy to clipboard operation
pyrollbar copied to clipboard

fallback to unittest when unittest2 is not available

Open pgajdos opened this issue 5 years ago • 10 comments

unittest2 is not neccessary in python3

pgajdos avatar Jun 03 '20 09:06 pgajdos

@pgajdos Well, the question remains: why is it needed for Python 2.7? (it would be nice to mention it in changelog/spec file)? Is it really needed?

mcepl avatar Jun 22 '20 06:06 mcepl

@mcepl

[    7s] ____ SerializableTransformTest.test_encode_with_custom_repr_returns_object _____
[    7s] 
[    7s] self = <rollbar.test.test_serializable_transform.SerializableTransformTest testMethod=test_encode_with_custom_repr_returns_object>
[    7s] 
[    7s]     def test_encode_with_custom_repr_returns_object(self):
[    7s]         class CustomRepr(object):
[    7s]             def __repr__(self):
[    7s]                 return {'hi': 'there'}
[    7s]     
[    7s]         start = {'hello': 'world', 'custom': CustomRepr()}
[    7s]     
[    7s]         serializable = SerializableTransform(whitelist_types=[CustomRepr])
[    7s]         result = transforms.transform(start, serializable)
[    7s] >       self.assertRegex(result['custom'], "<class '.*CustomRepr'>")
[    7s] E       AttributeError: 'SerializableTransformTest' object has no attribute 'assertRegex'
[    7s] 

I think it is lost time to deal with it more as 2.7 is eol.

pgajdos avatar Jun 25 '20 08:06 pgajdos

import six

six.assertRegex(self, result['custom'], "<class '.*CustomRepr'>")

I think it is lost time to deal with it more as 2.7 is eol.

Not for SLE (although python-rollbar is not in SLE).

mcepl avatar Jun 25 '20 08:06 mcepl

@mcepl

import six

six.assertRegex(self, result['custom'], "<class '.*CustomRepr'>")

Unfortunately, that does not work for me so.

I think it is lost time to deal with it more as 2.7 is eol.

Not for SLE (although python-rollbar is not in SLE).

I do not discuss downstream matters in upstream issues. (I do not see the issue with above patch in SLE, though, perhaps bit of reasoning would help me understand the problem.)

pgajdos avatar Jun 25 '20 12:06 pgajdos

Done.

pgajdos avatar Jul 16 '20 09:07 pgajdos

Hmm, @mrunalk and @mcepl: so should I actually revert to (original) cdfc35b?

I do not insist on making this change myself, so feel free to do the change yourself, if you wish -- I can just file an issue, if you think it would be better.

pgajdos avatar Aug 04 '20 12:08 pgajdos

Hmm, @mrunalk and @mcepl: so should I actually revert to (original) cdfc35b?

I do not insist on making this change myself, so feel free to do the change yourself, if you wish -- I can just file an issue, if you think it would be better.

I still haven’t got a reply to my answer what capabilities of python3/unittest2 is used in the test suite. Do we need unittest2 (with Python 2.7) at all?

mcepl avatar Aug 04 '20 17:08 mcepl

@mcepl

See https://github.com/rollbar/pyrollbar/pull/340#issuecomment-649349929.

pgajdos avatar Aug 05 '20 08:08 pgajdos

Hmm, @mrunalk and @mcepl: so should I actually revert to (original) cdfc35b?

I do not insist on making this change myself, so feel free to do the change yourself, if you wish -- I can just file an issue, if you think it would be better.

I am OK removing 'unittest2' but Not OK with removing support for python2 at this time. Alternatively I can merge your original patch of 'fallback to unittest when unittest2 is not available' if you can provide some explanation on what is motivating on this change that will help understand the context.

mrunalk avatar Aug 05 '20 20:08 mrunalk

I am OK removing 'unittest2' but Not OK with removing support for python2 at this time.

I completely agree, see the linked pull request.

mcepl avatar Aug 06 '20 06:08 mcepl