Get (most of) test_type_name passing#3387
Conversation
| # TODO: RUSTPYTHON (https://github.com/RustPython/RustPython/issues/935) | ||
| # with self.assertRaises(ValueError): | ||
| # type('A\udcdcB', (), {}) |
There was a problem hiding this comment.
We always prefer expectedFailure decorator than commenting out. (Guess what happens when this is fixed later)
There was a problem hiding this comment.
Yeah, that's a very fair point. In this case, I've fixed all but these failures, which are due to a much broader bug than I can reasonably fix alongside all these other failures. With a decorator, none of these assertions would run, so regressions could occur in all of the ones that I've just fixed. Should I move these assertions to a separate test to decorate? Or perhaps I can use it as a context manager? What do you think?
There was a problem hiding this comment.
OK, I've just pushed up a fix: use self.assertRaises(AssertionError) as a context manager around the expected failures: once they're passing, that will fail the test.
There was a problem hiding this comment.
We just left it or added a test in extra_tests, but this is an interesting approach.
|
@moreal could you please review this PR? the |
00a552d to
e7b9462
Compare
e7b9462 to
b010f24
Compare
This is presumably a hard requirement for CPython, but even though we don't use null-terminated strings, we should retain consistency with their API.
This matches CPython's behaviour, and means that setting `__name__` won't modify `__qualname__`. (This is done in type_new_set_ht_name in typeobject.c in CPython.)
The remaining failures are due to what appears to be a fundamental difference between how RustPython and CPython handle surrogate characters/codepoints-which-aren't-characters. They are wrapped with `self.assertRaises(AssertionError)` so we will notice once they start passing. RustPython#935 is most likely related.
Evidently the changes to how we handle `__name__` and `__qualname__` have fixed the errors we were seeing in test_enum and test_typing.
406ea2d to
f5fa662
Compare
See individual commits for details.