Skip to content

Get (most of) test_type_name passing#3387

Merged
youknowone merged 6 commits into
RustPython:mainfrom
OddBloke:oddbloke/type_name
Apr 15, 2022
Merged

Get (most of) test_type_name passing#3387
youknowone merged 6 commits into
RustPython:mainfrom
OddBloke:oddbloke/type_name

Conversation

@OddBloke
Copy link
Copy Markdown
Collaborator

See individual commits for details.

Comment thread Lib/test/test_builtin.py Outdated
Comment on lines +2064 to +2066
# TODO: RUSTPYTHON (https://github.com/RustPython/RustPython/issues/935)
# with self.assertRaises(ValueError):
# type('A\udcdcB', (), {})
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We always prefer expectedFailure decorator than commenting out. (Guess what happens when this is fixed later)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We just left it or added a test in extra_tests, but this is an interesting approach.

@youknowone
Copy link
Copy Markdown
Member

@moreal could you please review this PR? the slot_name looks different than your idea before. So I want to listen your opinion about it.

Comment thread vm/src/builtins/pytype.rs Outdated
OddBloke and others added 6 commits April 16, 2022 00:37
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.
Copy link
Copy Markdown
Member

@youknowone youknowone left a comment

Choose a reason for hiding this comment

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

@OddBloke thanks!

@youknowone youknowone merged commit 1d68ade into RustPython:main Apr 15, 2022
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.

3 participants