Show More
@@ -21,6 +21,7 b' Authors:' | |||||
21 | # Imports |
|
21 | # Imports | |
22 | #----------------------------------------------------------------------------- |
|
22 | #----------------------------------------------------------------------------- | |
23 |
|
23 | |||
|
24 | import re | |||
24 | import sys |
|
25 | import sys | |
25 | from unittest import TestCase |
|
26 | from unittest import TestCase | |
26 |
|
27 | |||
@@ -30,7 +31,7 b' from IPython.utils.traitlets import (' | |||||
30 | HasTraits, MetaHasTraits, TraitType, Any, CBytes, |
|
31 | HasTraits, MetaHasTraits, TraitType, Any, CBytes, | |
31 | Int, Long, Integer, Float, Complex, Bytes, Unicode, TraitError, |
|
32 | Int, Long, Integer, Float, Complex, Bytes, Unicode, TraitError, | |
32 | Undefined, Type, This, Instance, TCPAddress, List, Tuple, |
|
33 | Undefined, Type, This, Instance, TCPAddress, List, Tuple, | |
33 | ObjectName, DottedObjectName |
|
34 | ObjectName, DottedObjectName, CRegExp | |
34 | ) |
|
35 | ) | |
35 | from IPython.utils import py3compat |
|
36 | from IPython.utils import py3compat | |
36 | from IPython.testing.decorators import skipif |
|
37 | from IPython.testing.decorators import skipif | |
@@ -890,3 +891,18 b' class TestMultiTuple(TraitTestBase):' | |||||
890 | _default_value = (99,b'bottles') |
|
891 | _default_value = (99,b'bottles') | |
891 | _good_values = [(1,b'a'), (2,b'b')] |
|
892 | _good_values = [(1,b'a'), (2,b'b')] | |
892 | _bad_values = ((),10, b'a', (1,b'a',3), (b'a',1), (1, u'a')) |
|
893 | _bad_values = ((),10, b'a', (1,b'a',3), (b'a',1), (1, u'a')) | |
|
894 | ||||
|
895 | class CRegExpTrait(HasTraits): | |||
|
896 | ||||
|
897 | value = CRegExp(r'') | |||
|
898 | ||||
|
899 | class TestCRegExp(TraitTestBase): | |||
|
900 | ||||
|
901 | def coerce(self, value): | |||
|
902 | return re.compile(value) | |||
|
903 | ||||
|
904 | obj = CRegExpTrait() | |||
|
905 | ||||
|
906 | _default_value = re.compile(r'') | |||
|
907 | _good_values = [r'\d+', re.compile(r'\d+')] | |||
|
908 | _bad_values = [r'(', None, ()] |
General Comments 0
You need to be logged in to leave comments.
Login now