(self)
| 278 | |
| 279 | @requires_IEEE_754 |
| 280 | def test_specific_values(self): |
| 281 | # Some tests need to be skipped on ancient OS X versions. |
| 282 | # See issue #27953. |
| 283 | SKIP_ON_TIGER = {'tan0064'} |
| 284 | |
| 285 | osx_version = None |
| 286 | if sys.platform == 'darwin': |
| 287 | version_txt = platform.mac_ver()[0] |
| 288 | try: |
| 289 | osx_version = tuple(map(int, version_txt.split('.'))) |
| 290 | except ValueError: |
| 291 | pass |
| 292 | |
| 293 | def rect_complex(z): |
| 294 | """Wrapped version of rect that accepts a complex number instead of |
| 295 | two float arguments.""" |
| 296 | return cmath.rect(z.real, z.imag) |
| 297 | |
| 298 | def polar_complex(z): |
| 299 | """Wrapped version of polar that returns a complex number instead of |
| 300 | two floats.""" |
| 301 | return complex(*polar(z)) |
| 302 | |
| 303 | for id, fn, ar, ai, er, ei, flags in parse_testfile(test_file): |
| 304 | arg = complex(ar, ai) |
| 305 | expected = complex(er, ei) |
| 306 | |
| 307 | # Skip certain tests on OS X 10.4. |
| 308 | if osx_version is not None and osx_version < (10, 5): |
| 309 | if id in SKIP_ON_TIGER: |
| 310 | continue |
| 311 | |
| 312 | if fn == 'rect': |
| 313 | function = rect_complex |
| 314 | elif fn == 'polar': |
| 315 | function = polar_complex |
| 316 | else: |
| 317 | function = getattr(cmath, fn) |
| 318 | if 'divide-by-zero' in flags or 'invalid' in flags: |
| 319 | try: |
| 320 | actual = function(arg) |
| 321 | except ValueError: |
| 322 | continue |
| 323 | else: |
| 324 | self.fail('ValueError not raised in test ' |
| 325 | '{}: {}(complex({!r}, {!r}))'.format(id, fn, ar, ai)) |
| 326 | |
| 327 | if 'overflow' in flags: |
| 328 | try: |
| 329 | actual = function(arg) |
| 330 | except OverflowError: |
| 331 | continue |
| 332 | else: |
| 333 | self.fail('OverflowError not raised in test ' |
| 334 | '{}: {}(complex({!r}, {!r}))'.format(id, fn, ar, ai)) |
| 335 | |
| 336 | actual = function(arg) |
| 337 |
nothing calls this directly
no test coverage detected