8000 bpo-26680: Incorporate is_integer in all built-in and standard library numeric types by rob-smallshire · Pull Request #6121 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-26680: Incorporate is_integer in all built-in and standard library numeric types #6121

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

Merged
merged 10 commits into from
Oct 1, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
bpo-26680: Adds tests for Fraction.is_integer called as an instance m…
…ethod.

The tests for the Rational abstract base class use an unbound
method to sidestep the inability to directly instantiate Rational.
These tests check that everything works correct as an instance method.
  • Loading branch information
rob-smallshire committed Sep 18, 2020
commit cc07ee5e857d0b10451b086a7412d20a9d6c8133
11 changes: 11 additions & 0 deletions Lib/test/test_fractions.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,17 @@ def denominator(self):
self.assertEqual(type(f.numerator), myint)
self.assertEqual(type(f.denominator), myint)

def test_is_integer(self):
# Issue #26680: Incorporating number.is_integer into Fraction
self.assertTrue(F(-1, 1).is_integer())
self.assertTrue(F(0, 1).is_integer())
self.assertTrue(F(1, 1).is_integer())
self.assertTrue(F(42, 1).is_integer())
self.assertTrue(F(2, 2).is_integer())
self.assertTrue(F(8, 4).is_integer())
self.assertFalse(F(1, 2).is_integer())
self.assertFalse(F(1, 3).is_integer())
self.assertFalse(F(2, 3).is_integer())

if __name__ == '__main__':
unittest.main()
0