Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fallback to unittest when unittest2 is not available #340

Closed
wants to merge 3 commits into from
Closed

fallback to unittest when unittest2 is not available #340

wants to merge 3 commits into from

Conversation

pgajdos
Copy link
Contributor

@pgajdos pgajdos commented Jun 3, 2020

unittest2 is not neccessary in python3

@mcepl
Copy link
Contributor

mcepl commented Jun 22, 2020

@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?

@pgajdos
Copy link
Contributor Author

pgajdos commented Jun 25, 2020

@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.

@mcepl
Copy link
Contributor

mcepl commented Jun 25, 2020

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).

@pgajdos
Copy link
Contributor Author

pgajdos commented Jun 25, 2020

@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.)

Copy link
Contributor

@letaniaferreira letaniaferreira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -1,9 +1,12 @@
import unittest2
try:
import unittest2 as unittest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your change. I don't think we even need to fallback on unittest2 as Python 2+ has been EOLed. Just move ahead with replacing it to unittest.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it doesn’t save me. We have rollbar in Leap 15.* so we still build python2- packages. I don’t want to knowingly break python2 compatibility if I can help it. Do you know rollbar functionality available only in Python 3.* or unittest2 respectively?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcepl, Thank you for your feedback. We are definitely not removing the support for python2 yet. If we can replace unittest2 with unittest without breaking existing tests and builds that will be great.

@pgajdos
Copy link
Contributor Author

pgajdos commented Jul 16, 2020

Done.

@@ -2,16 +2,6 @@ sudo: false
language: python
matrix:
include:
- python: "2.7"
Copy link
Contributor

@mrunalk mrunalk Jul 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not removing support for Python2+ yet so please revert this part. May I know your motivation behind supporting unittest?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pgajdos ???

@@ -1,9 +1,12 @@
import unittest2
try:
import unittest2 as unittest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcepl, Thank you for your feedback. We are definitely not removing the support for python2 yet. If we can replace unittest2 with unittest without breaking existing tests and builds that will be great.

bmwiedemann added a commit to bmwiedemann/openSUSE that referenced this pull request Jul 18, 2020
https://build.opensuse.org/request/show/821667
by user mcepl + dimstar_suse
- Upstream doesn't care about unittest2 at all
  (gh#rollbar/pyrollbar#340), we can just ignore it. Adjust
  python-rollbar-no-unittest2.patch accordingly.
@pgajdos
Copy link
Contributor Author

pgajdos commented Aug 4, 2020

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.

@mcepl
Copy link
Contributor

mcepl commented Aug 4, 2020

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?

@pgajdos
Copy link
Contributor Author

pgajdos commented Aug 5, 2020

@mcepl

See #340 (comment).

@mrunalk
Copy link
Contributor

mrunalk commented Aug 5, 2020

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.

@mcepl
Copy link
Contributor

mcepl commented Aug 6, 2020

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

I completely agree, see the linked pull request.

bmwiedemann added a commit to bmwiedemann/openSUSE that referenced this pull request Aug 6, 2020
https://build.opensuse.org/request/show/824631
by user mcepl + dimstar_suse
- Replace self.assertRegex with six.assertRegex in
  python-rollbar-no-unittest2.patch to finally unrequire
  unittest2 (gh#rollbar/pyrollbar#340).
- Update the patch according to the pending pull request
  gh#rollbar/pyrollbar#346.
@mcepl mcepl mentioned this pull request Feb 23, 2023
@brianr brianr mentioned this pull request Feb 23, 2023
12 tasks
@brianr brianr closed this in bcc024e Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants