Skip to content
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

Allowed __repr__ of a poorly constructed Unit. #134

Merged
merged 1 commit into from Jan 22, 2019

Conversation

pelson
Copy link
Member

@pelson pelson commented Jan 21, 2019

Rationale

Addresses the comment in #133 (comment), namely that pytest tries calling Unit.__repr__ when a test fails, even if that test was the constructor of Unit. Essentially, unless pytest-dev/pytest#4659 is solved directly, we should strive to have a repr that can be a little more fault tolerant (rather than Segmentation Faulting as it currently does).

Implications

  • is_unknown now also checks to see if the ut_unit pointer is None, if it is, the unit is considered unknown.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 89.581% when pulling 6c9978c on pelson:repr_fault_tolerant into 1836f32 on SciTools:master.

@pelson pelson mentioned this pull request Jan 21, 2019
@bjlittle bjlittle self-assigned this Jan 22, 2019
@@ -1128,7 +1128,7 @@ def is_unknown(self):
False

"""
return self.category == _CATEGORY_UNKNOWN
return self.category == _CATEGORY_UNKNOWN or self.ut_unit is None
Copy link
Member

Choose a reason for hiding this comment

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

@pelson Could self.ut_unit also be _ud.NULL_UNIT? If so, does this need to be included here in this check?

Copy link
Member Author

Choose a reason for hiding this comment

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

The only way it can be NULL_UNIT is if the constructor succeeded and it is one of _NO_UNIT or _UNKNOWN_UNIT.

We shouldn't consider "no unit" unknown, so the only case that it can be NULL_UNIT is if self.category == _CATEGORY_UNKNOWN.

In summary, I don't think so.

@bjlittle
Copy link
Member

Thanks @pelson

@bjlittle bjlittle merged commit 18b72bc into SciTools:master Jan 22, 2019
@pelson pelson deleted the repr_fault_tolerant branch July 31, 2019 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants