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

ENH: skip or avoid gc/objectmodel differences btwn pypy and cpython #7912

Merged
merged 1 commit into from
Aug 15, 2016
Merged

ENH: skip or avoid gc/objectmodel differences btwn pypy and cpython #7912

merged 1 commit into from
Aug 15, 2016

Conversation

mattip
Copy link
Member

@mattip mattip commented Aug 6, 2016

three classes of fixes when running tests with PyPy:

  • skip test_closing_fid
  • skip all tests of sys.getsizeof()
  • always return True where sys.getrefcount() is used by defining a hackish AlwaysTrue class

return - other
def __add__(self, other):
return other
sys.getrefcount = lambda x: AlwaysTrue()
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure Numpy should monkeypatch sys on import.
Probably simpler to guard the few asserts with if not IS_PYPY

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, monkeypatching the standard library sounds evil ;)

@mattip
Copy link
Member Author

mattip commented Aug 7, 2016

Fixed as per comments

@@ -6355,50 +6360,52 @@ def test_string(self):
assert_equal(np.where(False, b, a), "abcd")


class TestSizeOf(TestCase):
if not IS_PYPY:
Copy link
Member

Choose a reason for hiding this comment

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

Another way to do this in Nose is probably to raise SkipTest in def setup(self): ...

Copy link
Member

Choose a reason for hiding this comment

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

Interesting suggestion. Probably not as obvious in reading the code, but otherwise cleaner, at least until we drop the now abandoned Nose.

Copy link
Member Author

Choose a reason for hiding this comment

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

Using dec.skip() in a setup() class method did not skip the class. It seems to skip one or more tests but not all. I could not find documentation or examples of how to do this in the 10 minutes I tried.

@pv
Copy link
Member

pv commented Aug 15, 2016

LGTM, @charris merge?

@@ -34,6 +34,7 @@ def iter_iterindices(i):
i.iternext()
return ret

@np.testing.dec.skipif(not HAS_REFCOUNT, "python does not have sys.getrefcount")
Copy link
Member

Choose a reason for hiding this comment

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

Should be @dec.skipif(not HAS_REFCOUNT, "python does not have sys.getrefcount"), dec is imported above. That also brings the line length under the 79 character limit...

@charris
Copy link
Member

charris commented Aug 15, 2016

Looks straight forward. The only nit I see is that in the tests dec is already imported from numpy.testing, so no need for the long version @np.testing.dec.

@mattip
Copy link
Member Author

mattip commented Aug 15, 2016

Thanks for the reviews. I will update the pull request accordingly

@charris charris merged commit 63d30ba into numpy:master Aug 15, 2016
@charris
Copy link
Member

charris commented Aug 15, 2016

Thanks @mattip .

@mattip mattip deleted the pypy-fixes2 branch June 1, 2017 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants