Skip to content

Conversation

mafshari64
Copy link
Contributor

ci: no-compile

def test_invalid_period_type(self):
"""Test invalid input types."""
with self.assertRaises(typeguard.TypeCheckError):
Auto(period="invalid")
Copy link
Member

Choose a reason for hiding this comment

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

What's the difference between this line and line 57+58?
And why are both tests needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The key difference is when and how the invalid value is introduced.

test_invalid_period_type is done During def init. Auto is decorated with @typeguard.typechecked, typeguard automatically checks the type of auto period. so the error happens during object creation.

test_check_invalid_period is During check(). first we create a valid object: Auto(period=10). then, we manually break it by assigning an invalid value to auto.period.. Typeguard does not automatically recheck assignments. auto.check(), then raises a TypeError because period is no longer a TimeStepSpec.

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.

2 participants