Skip to content

Commit

Permalink
Test for TypeError if pattern is used with a property_type that is no…
Browse files Browse the repository at this point in the history
…t str
  • Loading branch information
joetayloruk committed Mar 12, 2021
1 parent 5591d69 commit de64dc6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions features/dict.feature
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,10 @@ Feature: Test dictionary DOM objects
"""


Scenario: Fail if pattern is supplied and property_type is not str

When we try to load the Python module invalid_pattern_not_str.py
Then a TypeError is raised with text:
"""
Parameter 'pattern' can only be set if 'property_type' is str.
"""
6 changes: 6 additions & 0 deletions features/examples/modules/invalid_pattern_not_str.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from wysdom import UserObject, UserProperty


class Address(UserObject):
zip_code: int = UserProperty(int, pattern=r"^[0-9]{5}$")

0 comments on commit de64dc6

Please sign in to comment.