Permalink
Browse files

Add tests for CRegExp.

  • Loading branch information...
1 parent 7c55889 commit 5ba8058f3075e41396227ec8ac3bd30ba1cd1180 @bfroehle committed May 10, 2012
Showing with 17 additions and 1 deletion.
  1. +17 −1 IPython/utils/tests/test_traitlets.py
@@ -21,6 +21,7 @@
# Imports
#-----------------------------------------------------------------------------
+import re
import sys
from unittest import TestCase
@@ -30,7 +31,7 @@
HasTraits, MetaHasTraits, TraitType, Any, CBytes,
Int, Long, Integer, Float, Complex, Bytes, Unicode, TraitError,
Undefined, Type, This, Instance, TCPAddress, List, Tuple,
- ObjectName, DottedObjectName
+ ObjectName, DottedObjectName, CRegExp
)
from IPython.utils import py3compat
from IPython.testing.decorators import skipif
@@ -890,3 +891,18 @@ class TestMultiTuple(TraitTestBase):
_default_value = (99,b'bottles')
_good_values = [(1,b'a'), (2,b'b')]
_bad_values = ((),10, b'a', (1,b'a',3), (b'a',1), (1, u'a'))
+
+class CRegExpTrait(HasTraits):
+
+ value = CRegExp(r'')
+
+class TestCRegExp(TraitTestBase):
+
+ def coerce(self, value):
+ return re.compile(value)
+
+ obj = CRegExpTrait()
+
+ _default_value = re.compile(r'')
+ _good_values = [r'\d+', re.compile(r'\d+')]
+ _bad_values = [r'(', None, ()]

0 comments on commit 5ba8058

Please sign in to comment.