Skip to content

Commit

Permalink
Add tests for CRegExp.
Browse files Browse the repository at this point in the history
  • Loading branch information
bfroehle committed May 10, 2012
1 parent 7c55889 commit 5ba8058
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion IPython/utils/tests/test_traitlets.py
Expand Up @@ -21,6 +21,7 @@
# Imports
#-----------------------------------------------------------------------------

import re
import sys
from unittest import TestCase

Expand All @@ -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
Expand Down Expand Up @@ -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.