Skip to content

Fix unittest DeprecationWarnings#2089

Merged
takluyver merged 6 commits into
ipython:masterfrom
bfroehle:unittest_deprecation_warnings
Jul 18, 2012
Merged

Fix unittest DeprecationWarnings#2089
takluyver merged 6 commits into
ipython:masterfrom
bfroehle:unittest_deprecation_warnings

Conversation

@bfroehle

@bfroehle bfroehle commented Jul 3, 2012

Copy link
Copy Markdown
Contributor

Several unittest.TestCase methods were deprecated in Python 2.7.

I've attempted to normalize our tests to the currently approved methods:

  • assert_ -> assertTrue
  • assertEquals -> assertEqual
  • assertNotEquals -> assertNotEqual

In addition, this impacts nose.tools which generates some methods automatically:

  • nt.assert_equals -> nt.assert_equal
  • nt.assert_not_equals -> nt.assert_not_equal

These fixes, while seemingly minor, really cut down on the verbosity of the output when running iptest with PYTHONWARNINGS=d in Python 3.2.

I've done a little testing in Python 2.7 and 3.2. I haven't tested Python 2.6, but I believe all of these aliases were available in that release.

@takluyver

Copy link
Copy Markdown
Member

Aside: I think most uses of assertTrue would be better as plain assert statements. The error message "False is not True" is rarely informative. But that's a style change, and I'm happy just working that in when I change tests.

I think the changes make sense, but I'll let someone else have a glance at it. The tests are running now.

@takluyver

Copy link
Copy Markdown
Member

Test results for commit fdc22f7 merged into master
Platform: linux2

  • python2.7: OK (libraries not available: oct2py rpy2)
  • python3.1: OK (libraries not available: cython matplotlib numpy oct2py pymongo qt rpy2 wx wx.aui zmq)
  • python3.2: OK (libraries not available: cython oct2py pymongo rpy2 wx wx.aui)

Not available for testing: python2.6

@Carreau

Carreau commented Jul 13, 2012

Copy link
Copy Markdown
Member

This one have a merge conflict...
(also I wouldn't touch deathrow as we are avoiding it in 2to3 refactor)

@bfroehle

Copy link
Copy Markdown
Contributor Author

Okay, rebased and removed any modifications to quarantine / deathrow.

@bfroehle

Copy link
Copy Markdown
Contributor Author

I think I got most of the deprecated methods in this pull request, but there might be a few missing still. In particular there are a bunch of calls to tt.assert_equals in IPython.core.tests.test_run that I left alone.

@minrk

minrk commented Jul 15, 2012

Copy link
Copy Markdown
Member

I may be missing something, but why did you leave them alone in test_run?

@bfroehle

Copy link
Copy Markdown
Contributor Author

Well, I wasn't sure what tt was.

Update: I see now that tt.assert_equals is essentially the same as nt.assert_equals, so I've applied the same transformation:

  • tt.assert_equals -> tt.assert_equal

@minrk

minrk commented Jul 16, 2012

Copy link
Copy Markdown
Member

There are only a few tt.assert_foo (test_run and test_magic), and tt.assert_foo is nt.assert_foo.

I would suggest changing those calls to use the real nt.assert_foo, and remove this whole block.

@bfroehle

Copy link
Copy Markdown
Contributor Author

@minrk Thanks for doing the research. I've removed that block of code and replaced tt.assert_foos with nt.assert_foo.

@takluyver

Copy link
Copy Markdown
Member

(Note this now has a conflict, so it will need a quick rebase)

@bfroehle

Copy link
Copy Markdown
Contributor Author

Rebased & force pushed.

To git@github.com:bfroehle/ipython.git
+ 4e6d0ee...07ea078 unittest_deprecation_warnings -> unittest_deprecation_warnings (forced update)

@takluyver

Copy link
Copy Markdown
Member

Test results for commit 07ea078 merged into master
Platform: linux2

  • python2.7: OK (libraries not available: oct2py pymongo tornado wx wx.aui)
  • python3.2: OK (libraries not available: oct2py pymongo wx wx.aui)

Not available for testing: python2.6

@minrk

minrk commented Jul 17, 2012

Copy link
Copy Markdown
Member

Test results for commit 07ea078 merged into master
Platform: darwin

  • python2.6: OK (libraries not available: cython matplotlib oct2py pygments pymongo qt rpy2 tornado wx wx.aui)
  • python2.7: OK (libraries not available: oct2py wx wx.aui)
  • python3.2: OK (libraries not available: cython matplotlib oct2py pymongo qt rpy2 wx wx.aui)

Not available for testing: python3.1

@takluyver

Copy link
Copy Markdown
Member

I've done a quick scan through (as of 3ac8c33) to check that there's nothing odd lurking in that big diff. I see Min's tests include Python 2.6, so I'm happy for this to go in now.

@minrk

minrk commented Jul 17, 2012

Copy link
Copy Markdown
Member

+1 to merge, thanks!

takluyver added a commit that referenced this pull request Jul 18, 2012
@takluyver takluyver merged commit a91d55d into ipython:master Jul 18, 2012
@takluyver

Copy link
Copy Markdown
Member

Merged this one.

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
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.

4 participants